From 99adbc5a30c9128d005dc8096d58c5b320f67fef Mon Sep 17 00:00:00 2001 From: Soybean <2570172956@qq.com> Date: Sat, 18 Sep 2021 11:32:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(projects):=20=E4=BF=AE=E5=A4=8D=E5=A4=9A?= =?UTF-8?q?=E9=A1=B5=E7=AD=BE=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BasicLayout/components/GlobalTab/index.vue | 2 +- src/store/modules/app/index.ts | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/layouts/BasicLayout/components/GlobalTab/index.vue b/src/layouts/BasicLayout/components/GlobalTab/index.vue index 18ed1a80..12dee46d 100644 --- a/src/layouts/BasicLayout/components/GlobalTab/index.vue +++ b/src/layouts/BasicLayout/components/GlobalTab/index.vue @@ -14,7 +14,7 @@ :closable="item.name !== ROUTE_HOME.name" size="large" @click="handleClickTab(item.fullPath)" - @close="removeMultiTab(item.fullPath)" + @close.stop="removeMultiTab(item.fullPath)" > {{ item.meta?.title }} diff --git a/src/store/modules/app/index.ts b/src/store/modules/app/index.ts index b29154b9..c6acd4dd 100644 --- a/src/store/modules/app/index.ts +++ b/src/store/modules/app/index.ts @@ -74,12 +74,14 @@ const appStore = defineStore({ }, /** 删除多页签的数据 */ removeMultiTab(fullPath: string) { - const index = this.getIndexInTabRoutes(fullPath); - if (index > -1) { - this.multiTab.routes = this.multiTab.routes.filter(item => item.fullPath !== fullPath); - const { routes } = this.multiTab; - const activePath = routes[routes.length - 1].fullPath; + const isActive = this.multiTab.activeRoute === fullPath; + const { routes } = this.multiTab; + const updateRoutes = routes.filter(v => v.fullPath !== fullPath); + this.multiTab.routes = updateRoutes; + if (isActive) { + const activePath = updateRoutes[updateRoutes.length - 1].fullPath; router.push(activePath); + this.setActiveMultiTab(activePath); } }, /** 点击单个页签tab */