feat: add tabs demo

This commit is contained in:
vben
2024-07-20 09:36:10 +08:00
parent 1fbf69e6eb
commit 30d4057216
10 changed files with 48 additions and 40 deletions

View File

@@ -28,6 +28,10 @@ interface TabsState {
* @zh_CN 当前打开的标签页列表
*/
tabs: TabDefinition[];
/**
* @zh_CN 更新时间用于一些更新场景使用watch深度监听的话会损耗性能
*/
updateTime?: number;
}
/**
@@ -306,11 +310,17 @@ const useCoreTabbarStore = defineStore('core-tabbar', {
const findTab = this.tabs.find(
(item) => getTabPath(item) === getTabPath(tab),
);
if (findTab) {
findTab.meta.newTabTitle = title;
await this.updateCacheTab();
}
},
async setUpdateTime() {
this.updateTime = Date.now();
},
/**
* @zh_CN 设置标签页顺序
* @param oldIndex
@@ -399,6 +409,7 @@ const useCoreTabbarStore = defineStore('core-tabbar', {
excludeCachedTabs: new Set(),
renderRouteView: true,
tabs: [],
updateTime: Date.now(),
}),
});