|
@@ -1,15 +1,14 @@
|
|
|
import { reactive, ref, nextTick } from 'vue'
|
|
import { reactive, ref, nextTick } from 'vue'
|
|
|
-import { getChartEditStore } from './useStore.hook'
|
|
|
|
|
|
|
+import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore'
|
|
|
import { loadingError } from '@/utils'
|
|
import { loadingError } from '@/utils'
|
|
|
|
|
|
|
|
-const chartEditStore = getChartEditStore()
|
|
|
|
|
|
|
+const chartEditStore = useChartEditStoreStore()
|
|
|
|
|
|
|
|
enum MenuEnum {
|
|
enum MenuEnum {
|
|
|
DELETE = 'delete'
|
|
DELETE = 'delete'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const useContextMenu = () => {
|
|
export const useContextMenu = () => {
|
|
|
- const showDropdownRef = ref(false)
|
|
|
|
|
const targetIndex = ref<number>(0)
|
|
const targetIndex = ref<number>(0)
|
|
|
|
|
|
|
|
// * 右键选项
|
|
// * 右键选项
|
|
@@ -29,21 +28,21 @@ export const useContextMenu = () => {
|
|
|
while (target instanceof SVGElement) {
|
|
while (target instanceof SVGElement) {
|
|
|
target = target.parentNode
|
|
target = target.parentNode
|
|
|
}
|
|
}
|
|
|
- showDropdownRef.value = false
|
|
|
|
|
|
|
+ chartEditStore.setRightMenuShow(false)
|
|
|
nextTick().then(() => {
|
|
nextTick().then(() => {
|
|
|
chartEditStore.setMousePosition(e.clientX, e.clientY)
|
|
chartEditStore.setMousePosition(e.clientX, e.clientY)
|
|
|
- showDropdownRef.value = true
|
|
|
|
|
|
|
+ chartEditStore.setRightMenuShow(true)
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// * 失焦
|
|
// * 失焦
|
|
|
const onClickoutside = (e: MouseEvent) => {
|
|
const onClickoutside = (e: MouseEvent) => {
|
|
|
- showDropdownRef.value = false
|
|
|
|
|
|
|
+ chartEditStore.setRightMenuShow(false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// * 事件处理
|
|
// * 事件处理
|
|
|
const handleMenuSelect = (key: string) => {
|
|
const handleMenuSelect = (key: string) => {
|
|
|
- showDropdownRef.value = false
|
|
|
|
|
|
|
+ chartEditStore.setRightMenuShow(false)
|
|
|
switch (key) {
|
|
switch (key) {
|
|
|
case MenuEnum.DELETE:
|
|
case MenuEnum.DELETE:
|
|
|
chartEditStore.removeComponentList(targetIndex.value)
|
|
chartEditStore.removeComponentList(targetIndex.value)
|
|
@@ -53,7 +52,6 @@ export const useContextMenu = () => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
return {
|
|
|
- showDropdownRef,
|
|
|
|
|
menuOptions,
|
|
menuOptions,
|
|
|
handleContextMenu,
|
|
handleContextMenu,
|
|
|
onClickoutside,
|
|
onClickoutside,
|