feat(all): add sub-setting
This commit is contained in:
12
src/hooks/event.ts
Normal file
12
src/hooks/event.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import {onMounted, onUnmounted} from "vue";
|
||||
import {emitter, EventKey} from "@/utils/eventBus.ts";
|
||||
|
||||
export function useWindowClick(cb: () => void) {
|
||||
onMounted(() => {
|
||||
emitter.on(EventKey.closeOther, cb)
|
||||
window.addEventListener('click', cb)
|
||||
})
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('click', cb)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user