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 */