fix(command): re-register when component activated

zio/stable
三咲智子 2022-12-30 03:57:39 +08:00
parent f1f2449559
commit 2332d7091a
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
1 changed files with 3 additions and 2 deletions

View File

@ -208,10 +208,11 @@ export const useCommandRegistry = defineStore('command', () => {
export const useCommand = (cmd: CommandProvider) => { export const useCommand = (cmd: CommandProvider) => {
const registry = useCommandRegistry() const registry = useCommandRegistry()
registry.register(cmd) const register = () => registry.register(cmd)
const cleanup = () => registry.remove(cmd) const cleanup = () => registry.remove(cmd)
register()
onActivated(register)
onDeactivated(cleanup) onDeactivated(cleanup)
tryOnScopeDispose(cleanup) tryOnScopeDispose(cleanup)
} }