fix: 修复多标签页保活问题 (#523)

This commit is contained in:
ngyyuusora 2023-05-26 13:45:08 +08:00 committed by GitHub
parent f9f9e91438
commit 89ccf19f58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,7 +36,8 @@ export const useTabsRouterStore = defineStore('tabsRouter', {
}, },
// 处理新增 // 处理新增
appendTabRouterList(newRoute: TRouterInfo) { appendTabRouterList(newRoute: TRouterInfo) {
const needAlive = !ignoreCacheRoutes.includes(newRoute.name as string); // 不要将判断条件newRoute.meta.keepAlive !== false修改为newRoute.meta.keepAlivestarter默认开启保活所以meta.keepAlive未定义时也需要进行保活只有显式说明false才禁用保活。
const needAlive = !ignoreCacheRoutes.includes(newRoute.name as string) && newRoute.meta?.keepAlive !== false;
if (!this.tabRouters.find((route: TRouterInfo) => route.path === newRoute.path)) { if (!this.tabRouters.find((route: TRouterInfo) => route.path === newRoute.path)) {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
this.tabRouterList = this.tabRouterList.concat({ ...newRoute, isAlive: needAlive }); this.tabRouterList = this.tabRouterList.concat({ ...newRoute, isAlive: needAlive });