diff --git a/useRightMenu.ts b/useRightMenu.ts new file mode 100644 index 0000000..52cd665 --- /dev/null +++ b/useRightMenu.ts @@ -0,0 +1,35 @@ +import { ref } from 'vue' +interface MenuItem { + text: string + click: () => void + keyCode?: string +} +interface ShowMenuConfig { + x: number + y: number + items: MenuItem[] +} +const visible = ref() +const x = ref() +const y = ref() +const items = ref() + +export function useRightMenu() { + function showMenu(config: ShowMenuConfig) { + x.value = config.x + y.value = config.y + items.value = config.items + visible.value = true + } + function hideMenu() { + visible.value = false + } + return { + x, + y, + items, + visible, + showMenu, + hideMenu + } +}