From ac3f0d60a756298ef50f9696094fe31fae02b4ee Mon Sep 17 00:00:00 2001 From: taqi be Date: Fri, 10 Jan 2025 15:19:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=96=87=E6=A1=A3=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E7=9A=84=E4=B8=80=E4=BA=9B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dashboard/Edfs-context-menu/index.vue | 19 ++++---- .../fileDoc/components/markdownDrawer.vue | 3 +- src/pages/fileDoc/index.vue | 43 ++++++++++++++----- 3 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/components/dashboard/Edfs-context-menu/index.vue b/src/components/dashboard/Edfs-context-menu/index.vue index 538711f..41b1df7 100644 --- a/src/components/dashboard/Edfs-context-menu/index.vue +++ b/src/components/dashboard/Edfs-context-menu/index.vue @@ -9,7 +9,7 @@ :class="{ active: menuStatus.show }" v-show="menuStatus.show" > - + @@ -19,14 +19,15 @@ import { useWindowResize } from '@/tools/common/hooks' import { useSlots } from 'vue' interface Props { - eventSourceClass: string - menuList?: any - disabledEmpty?: boolean + eventSourceClass: string // 事件源类名 + menuList?: any // 菜单列表 + disabledEmpty?: boolean // 是否禁用空白区域右键 } const slotMenu = !!useSlots().menu const emit = defineEmits<{ - visibleChange: [boolean, HTMLElement | null] + visibleChange: [boolean, HTMLElement | null], + beforeContextmenu:[any] }>() const props = withDefaults(defineProps(), { @@ -42,9 +43,7 @@ const menuStatus = reactive({ }) const menuData = computed(() => { - // if (!props.menuList && !eventData.value) - // console.warn('没有传入menuList 或者使用v-setItem传入数据') - return props?.menuList || eventData?.value || {} + return props?.menuList ?? [] }) watch( @@ -55,6 +54,7 @@ watch( ) async function onContextmenu(e: any) { + eventData.value = null menuStatus.show = false e.preventDefault() @@ -67,6 +67,9 @@ async function onContextmenu(e: any) { } const data = sourceElement ? (sourceElement as any)._vItem : 'custom' eventData.value = data + emit('before-contextmenu', eventData.value) + await nextTick() + currentElement.value = sourceElement setMenuPosition(e) } diff --git a/src/pages/fileDoc/components/markdownDrawer.vue b/src/pages/fileDoc/components/markdownDrawer.vue index 558f8de..490d804 100644 --- a/src/pages/fileDoc/components/markdownDrawer.vue +++ b/src/pages/fileDoc/components/markdownDrawer.vue @@ -11,7 +11,7 @@
{{ data.fileName }}
- +
@@ -32,6 +32,7 @@ import 'vditor/dist/index.css' import { vditorToolbar } from '../utils' interface Props { data: ContentType & { fileName: string } + isRootMd: boolean } const emits = defineEmits(['on-save']) const props = withDefaults(defineProps(), {}) diff --git a/src/pages/fileDoc/index.vue b/src/pages/fileDoc/index.vue index 5b4e12d..e9880a1 100644 --- a/src/pages/fileDoc/index.vue +++ b/src/pages/fileDoc/index.vue @@ -17,6 +17,8 @@ :disabledEmpty="false" @visibleChange="onVisibleChange" ref="contextMenuRef" + :menuList="dropdownMenu" + @beforeContextmenu="onBeforeContextmenu" >
@@ -56,11 +58,11 @@
-