koel/resources/assets/js/composables/useContextMenu.ts

23 lines
468 B
TypeScript
Raw Normal View History

2024-04-04 22:20:42 +00:00
import { ref } from 'vue'
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,
base,
2022-04-15 17:00:08 +00:00
open,
2022-04-20 10:20:09 +00:00
close,
trigger
2022-04-15 17:00:08 +00:00
}
}