fix(projects): 修复多页签删除功能

This commit is contained in:
Soybean 2021-09-18 11:32:53 +08:00
parent 248937479c
commit 99adbc5a30
2 changed files with 8 additions and 6 deletions

View File

@ -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 }}
</n-tag>

View File

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