diff --git a/src/layouts/index.tsx b/src/layouts/index.tsx index 7ed2aaa..3e567a4 100644 --- a/src/layouts/index.tsx +++ b/src/layouts/index.tsx @@ -168,7 +168,7 @@ export default defineComponent({ const renderContent = () => { const { showBreadcrumb, showFooter, isUseTabsRouter } = settingStore; - const { tabRouters } = tabsRouterStore; + const tabRouters = tabsRouterStore.tabRouters.filter((route) => route.isAlive || route.isHome); return ( // 如果存在多个滚动列表之间切换时,页面不刷新导致的样式问题 请设置key 但会导致多标签tab页的缓存失效 diff --git a/src/store/modules/tabs-router.ts b/src/store/modules/tabs-router.ts index 825e26b..235945c 100644 --- a/src/store/modules/tabs-router.ts +++ b/src/store/modules/tabs-router.ts @@ -19,7 +19,7 @@ const state = { // 不需要做多标签tabs页缓存的列表 值为每个页面对应的name 如 DashboardDetail // const ignoreCacheRoutes = ['DashboardDetail']; -const ignoreCacheRoutes = []; +const ignoreCacheRoutes = ['login']; export const useTabsRouterStore = defineStore('tabsRouter', { state: () => state, @@ -35,7 +35,7 @@ export const useTabsRouterStore = defineStore('tabsRouter', { }, // 处理新增 appendTabRouterList(newRoute: TRouterInfo) { - const needAlive = !ignoreCacheRoutes.includes(newRoute.name); + const needAlive = !ignoreCacheRoutes.includes(newRoute.name as string); if (!this.tabRouters.find((route: TRouterInfo) => route.path === newRoute.path)) { // eslint-disable-next-line no-param-reassign this.tabRouterList = this.tabRouterList.concat({ ...newRoute, isAlive: needAlive });