mirror of
https://github.com/Tencent/tdesign-vue-next-starter.git
synced 2024-12-23 08:46:39 +08:00
feat: ignore cache demo (#155)
* fix: tab routes cache fails * feat: add ignore cache routes demo
This commit is contained in:
parent
b7f80c31cc
commit
3a2d29df6c
|
@ -169,7 +169,8 @@ export default defineComponent({
|
|||
const { showBreadcrumb, showFooter, isUseTabsRouter } = settingStore;
|
||||
const { tabRouters } = tabsRouterStore;
|
||||
return (
|
||||
<t-layout class={[`${prefix}-layout`]} key={route.name}>
|
||||
// <t-layout class={[`${prefix}-layout`]} key={route.name}> 如果存在多个滚动列表之间切换时,页面不刷新导致的样式问题 请设置key 但会导致多标签tab页的缓存失效
|
||||
<t-layout class={[`${prefix}-layout`]}>
|
||||
{isUseTabsRouter && (
|
||||
<t-tabs
|
||||
theme="card"
|
||||
|
|
|
@ -8,6 +8,10 @@ const state = {
|
|||
isRefreshing: false,
|
||||
};
|
||||
|
||||
// 不需要做多标签tabs页缓存的列表 值为每个页面对应的name 如 DashboardDetail
|
||||
// const ignoreCacheRoutes = ['DashboardDetail'];
|
||||
const ignoreCacheRoutes = [];
|
||||
|
||||
export const useTabsRouterStore = defineStore('tabsRouter', {
|
||||
state: () => state,
|
||||
getters: {
|
||||
|
@ -20,9 +24,10 @@ export const useTabsRouterStore = defineStore('tabsRouter', {
|
|||
this.tabRouters[routeIdx].isAlive = !this.tabRouters[routeIdx].isAlive;
|
||||
},
|
||||
appendTabRouterList(newRoute: TRouterInfo) {
|
||||
const needAlive = !ignoreCacheRoutes.includes(newRoute.name);
|
||||
if (!this.tabRouters.find((route: TRouterInfo) => route.path === newRoute.path)) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
this.tabRouterList = this.tabRouterList.concat(newRoute);
|
||||
this.tabRouterList = this.tabRouterList.concat({ ...newRoute, isAlive: needAlive });
|
||||
}
|
||||
},
|
||||
subtractCurrentTabRouter(newRoute: TRouterInfo) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user