Add useRightMenu.ts

Signed-off-by: wsg123 <1453416853@qq.com>
This commit is contained in:
wsg123 2024-07-05 16:21:38 +08:00
parent 1a4b2a5879
commit c009909845
1 changed files with 35 additions and 0 deletions

35
useRightMenu.ts Normal file
View File

@ -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<MenuItem[]>()
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
}
}