import mitt, { type Handler } from "mitt"; import { onBeforeUnmount } from "vue"; export type Events = { scrollToTop: void; }; export const emitter = mitt(); export function useEvent( type: Key, handler: Handler, ) { const { on, off } = emitter; on(type, handler); onBeforeUnmount(() => { off(type, handler); }); }