2024-04-04 22:20:42 +00:00
|
|
|
import { ref } from 'vue'
|
2022-07-07 18:05:46 +00:00
|
|
|
import ContextMenuBase from '@/components/ui/ContextMenuBase.vue'
|
2022-04-20 10:20:09 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
export const useContextMenu = () => {
|
2022-04-24 08:29:14 +00:00
|
|
|
const base = ref<InstanceType<typeof ContextMenuBase>>()
|
2022-04-15 17:00:08 +00:00
|
|
|
|
2022-12-02 16:17:37 +00:00
|
|
|
const open = async (top: number, left: number) => await base.value?.open(top, left)
|
2022-04-15 17:00:08 +00:00
|
|
|
const close = () => base.value?.close()
|
|
|
|
|
2022-06-10 10:47:46 +00:00
|
|
|
const trigger = (func: Closure) => {
|
|
|
|
close()
|
|
|
|
func()
|
|
|
|
}
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
return {
|
2022-04-24 08:29:14 +00:00
|
|
|
ContextMenuBase,
|
2022-07-08 10:32:44 +00:00
|
|
|
base,
|
2022-04-15 17:00:08 +00:00
|
|
|
open,
|
2022-04-20 10:20:09 +00:00
|
|
|
close,
|
2022-07-08 10:32:44 +00:00
|
|
|
trigger
|
2022-04-15 17:00:08 +00:00
|
|
|
}
|
|
|
|
}
|