fix(command): re-register when component activated

This commit is contained in:
三咲智子 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

View file

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