feat: restore original admin shell quality
This commit is contained in:
@@ -12,6 +12,16 @@ import { useAppContextStore } from '#/store/app-context';
|
||||
import { normalizeHomePath } from '#/utils/legacy-home';
|
||||
|
||||
import { generateAccess } from './access';
|
||||
import { isLightTabRoute } from './light-menu';
|
||||
|
||||
function filterLightTabHistory<T extends { tabs?: unknown[] }>(history: T) {
|
||||
const tabs = Array.isArray(history.tabs) ? history.tabs : [];
|
||||
return {
|
||||
...history,
|
||||
cachedTabs: [],
|
||||
tabs: tabs.filter((tab) => isLightTabRoute(tab as any)),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用守卫配置
|
||||
@@ -39,10 +49,10 @@ function setupCommonGuard(router: Router) {
|
||||
|
||||
// 保存当前应用的 tab 历史到内存
|
||||
const currentAppKey = currentAppCode || 'main';
|
||||
tabHistoryByApp.set(currentAppKey, {
|
||||
tabHistoryByApp.set(currentAppKey, filterLightTabHistory({
|
||||
tabs: [...tabbarStore.tabs],
|
||||
cachedTabs: new Set(tabbarStore.cachedTabs),
|
||||
});
|
||||
}));
|
||||
|
||||
// 从 sessionStorage 加载新应用的 tab 历史
|
||||
const storageKey = `vben-admin-tabs-${appKey}`;
|
||||
@@ -51,8 +61,9 @@ function setupCommonGuard(router: Router) {
|
||||
if (savedHistory) {
|
||||
try {
|
||||
const parsed = JSON.parse(savedHistory);
|
||||
tabbarStore.tabs = parsed.tabs || [];
|
||||
tabbarStore.cachedTabs = new Set(parsed.cachedTabs || []);
|
||||
const lightHistory = filterLightTabHistory(parsed);
|
||||
tabbarStore.tabs = lightHistory.tabs || [];
|
||||
tabbarStore.cachedTabs = new Set(lightHistory.cachedTabs || []);
|
||||
} catch (error) {
|
||||
console.error('Failed to parse tab history:', error);
|
||||
tabbarStore.tabs = [];
|
||||
@@ -87,10 +98,12 @@ function setupCommonGuard(router: Router) {
|
||||
const storageKey = `vben-admin-tabs-${appKey}`;
|
||||
|
||||
const tabbarStore = useTabbarStore();
|
||||
const tabHistory = {
|
||||
const tabHistory = filterLightTabHistory({
|
||||
tabs: tabbarStore.tabs,
|
||||
cachedTabs: [...tabbarStore.cachedTabs],
|
||||
};
|
||||
});
|
||||
tabbarStore.tabs = tabHistory.tabs as any;
|
||||
tabbarStore.cachedTabs = new Set(tabHistory.cachedTabs as string[]);
|
||||
sessionStorage.setItem(storageKey, JSON.stringify(tabHistory));
|
||||
|
||||
// 关闭页面加载进度条
|
||||
|
||||
Reference in New Issue
Block a user