From 327522f2b73ae0e11f8ebbc39394b06029ce0b65 Mon Sep 17 00:00:00 2001 From: wyh <1402389435@qq.com> Date: Tue, 12 Apr 2022 12:11:53 +0800 Subject: [PATCH] fix: fix bug --- src/components/ContextMenu/index.ts | 2 ++ src/components/ContextMenu/src/ContextMenu.vue | 14 ++++++++++---- src/components/TagsView/src/TagsView.vue | 9 +++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/components/ContextMenu/index.ts b/src/components/ContextMenu/index.ts index e8059e4..2a7c1f0 100644 --- a/src/components/ContextMenu/index.ts +++ b/src/components/ContextMenu/index.ts @@ -1,8 +1,10 @@ import ContextMenu from './src/ContextMenu.vue' import { ElDropdown } from 'element-plus' +import type { RouteLocationNormalizedLoaded } from 'vue-router' export interface ContextMenuExpose { elDropdownMenuRef: ComponentRef + tagItem: RouteLocationNormalizedLoaded } export { ContextMenu } diff --git a/src/components/ContextMenu/src/ContextMenu.vue b/src/components/ContextMenu/src/ContextMenu.vue index b904786..5007121 100644 --- a/src/components/ContextMenu/src/ContextMenu.vue +++ b/src/components/ContextMenu/src/ContextMenu.vue @@ -1,8 +1,9 @@ diff --git a/src/components/TagsView/src/TagsView.vue b/src/components/TagsView/src/TagsView.vue index c142d71..c10a54a 100644 --- a/src/components/TagsView/src/TagsView.vue +++ b/src/components/TagsView/src/TagsView.vue @@ -205,15 +205,11 @@ const isActive = (route: RouteLocationNormalizedLoaded): boolean => { const itemRefs = useTemplateRefsList>() // 右键菜单装填改变的时候 -const visibleChange = ( - visible: boolean, - ref: ComponentRef -) => { - const uid = ref.$el['__vueParentComponent'].uid +const visibleChange = (visible: boolean, tagItem: RouteLocationNormalizedLoaded) => { if (visible) { for (const v of unref(itemRefs)) { const elDropdownMenuRef = v.elDropdownMenuRef - if (uid !== elDropdownMenuRef?.$el['__vueParentComponent'].uid) { + if (tagItem.fullPath !== v.tagItem.fullPath) { elDropdownMenuRef?.handleClose() } } @@ -330,6 +326,7 @@ watch( ]" v-for="item in visitedViews" :key="item.fullPath" + :tag-item="item" :class="[ `${prefixCls}__item`, item?.meta?.affix ? `${prefixCls}__item--affix` : '',