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

23 lines
452 B
TypeScript
Raw Normal View History

2024-04-04 22:20:42 +00:00
import { ref } from 'vue'
2024-05-08 09:11:32 +00:00
import ContextMenu from '@/components/ui/ContextMenu.vue'
2022-04-20 10:20:09 +00:00
2022-04-15 17:00:08 +00:00
export const useContextMenu = () => {
2024-05-08 09:11:32 +00:00
const base = ref<InstanceType<typeof ContextMenu>>()
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 {
2024-05-08 09:11:32 +00:00
ContextMenu,
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
}
}