fix issue-166 (#168)

* fix issue-166

* fix issue-166
This commit is contained in:
Kerwin Bryant 2022-06-14 18:46:33 +08:00 committed by GitHub
parent 5ed7b4ead5
commit db3561aa88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -168,7 +168,7 @@ export default defineComponent({
const renderContent = () => { const renderContent = () => {
const { showBreadcrumb, showFooter, isUseTabsRouter } = settingStore; const { showBreadcrumb, showFooter, isUseTabsRouter } = settingStore;
const { tabRouters } = tabsRouterStore; const tabRouters = tabsRouterStore.tabRouters.filter((route) => route.isAlive || route.isHome);
return ( return (
// <t-layout class={[`${prefix}-layout`]} key={route.name}> 如果存在多个滚动列表之间切换时,页面不刷新导致的样式问题 请设置key 但会导致多标签tab页的缓存失效 // <t-layout class={[`${prefix}-layout`]} key={route.name}> 如果存在多个滚动列表之间切换时,页面不刷新导致的样式问题 请设置key 但会导致多标签tab页的缓存失效
<t-layout class={[`${prefix}-layout`]}> <t-layout class={[`${prefix}-layout`]}>

View File

@ -19,7 +19,7 @@ const state = {
// 不需要做多标签tabs页缓存的列表 值为每个页面对应的name 如 DashboardDetail // 不需要做多标签tabs页缓存的列表 值为每个页面对应的name 如 DashboardDetail
// const ignoreCacheRoutes = ['DashboardDetail']; // const ignoreCacheRoutes = ['DashboardDetail'];
const ignoreCacheRoutes = []; const ignoreCacheRoutes = ['login'];
export const useTabsRouterStore = defineStore('tabsRouter', { export const useTabsRouterStore = defineStore('tabsRouter', {
state: () => state, state: () => state,
@ -35,7 +35,7 @@ export const useTabsRouterStore = defineStore('tabsRouter', {
}, },
// 处理新增 // 处理新增
appendTabRouterList(newRoute: TRouterInfo) { 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)) { 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 });