feat: restore original admin shell quality
This commit is contained in:
@@ -27,6 +27,9 @@ const UserDropdown = defineAsyncComponent(() =>
|
||||
(module) => module.UserDropdown,
|
||||
),
|
||||
);
|
||||
const LockScreen = defineAsyncComponent(() =>
|
||||
import('@vben/layouts/es/lock-screen').then((module) => module.LockScreen),
|
||||
);
|
||||
const NotificationPopup = defineAsyncComponent(
|
||||
() => import('#/components/notification/NotificationPopup.vue'),
|
||||
);
|
||||
@@ -227,7 +230,7 @@ watch(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<BasicLayout>
|
||||
<BasicLayout @clear-preferences-and-logout="handleLogout">
|
||||
<template #user-dropdown>
|
||||
<UserDropdown
|
||||
:avatar
|
||||
@@ -286,5 +289,8 @@ watch(
|
||||
<LoginForm />
|
||||
</AuthenticationLoginExpiredModal>
|
||||
</template>
|
||||
<template #lock-screen>
|
||||
<LockScreen :avatar @to-login="handleLogout" />
|
||||
</template>
|
||||
</BasicLayout>
|
||||
</template>
|
||||
|
||||
@@ -20,11 +20,11 @@ export const overridesPreferences = defineOverridesPreferences({
|
||||
layout: 'header-sidebar-nav',
|
||||
},
|
||||
shortcutKeys: {
|
||||
enable: false,
|
||||
enable: true,
|
||||
globalLockScreen: false,
|
||||
globalLogout: true,
|
||||
globalPreferences: false,
|
||||
globalSearch: false,
|
||||
globalSearch: true,
|
||||
},
|
||||
theme: {
|
||||
mode: 'light',
|
||||
@@ -46,6 +46,9 @@ export const overridesPreferences = defineOverridesPreferences({
|
||||
fit: 'contain',
|
||||
source: Logo,
|
||||
},
|
||||
tabbar: {
|
||||
persist: false,
|
||||
},
|
||||
widget: {
|
||||
fullscreen: true,
|
||||
globalSearch: true,
|
||||
|
||||
@@ -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));
|
||||
|
||||
// 关闭页面加载进度条
|
||||
|
||||
@@ -31,10 +31,65 @@ export const LIGHT_MENU_NAMES = new Set([
|
||||
'userSettings',
|
||||
]);
|
||||
|
||||
const LIGHT_ROUTE_PATH_PREFIXES = [
|
||||
'/account-settings',
|
||||
'/ai-platform/agent',
|
||||
'/ai-platform/knowledge',
|
||||
'/ai-platform/model',
|
||||
'/ai-platform/workflow',
|
||||
'/ai-platform/workflow-runs',
|
||||
'/announcement',
|
||||
'/codex',
|
||||
'/dept',
|
||||
'/dict',
|
||||
'/file-manager',
|
||||
'/login-log',
|
||||
'/menu',
|
||||
'/message',
|
||||
'/page-render/main_home',
|
||||
'/permission',
|
||||
'/post',
|
||||
'/role',
|
||||
'/server-monitor',
|
||||
'/system-config',
|
||||
'/ui-config',
|
||||
'/user',
|
||||
];
|
||||
|
||||
export function isLightMenuName(name?: string) {
|
||||
return !name || LIGHT_MENU_NAMES.has(name);
|
||||
}
|
||||
|
||||
function normalizePath(path?: string) {
|
||||
if (!path) return '';
|
||||
return path.split('?')[0]?.replace(/\/$/, '') || '';
|
||||
}
|
||||
|
||||
export function isLightTabRoute(route: {
|
||||
fullPath?: string;
|
||||
matched?: Array<{ name?: unknown; path?: string }>;
|
||||
name?: unknown;
|
||||
path?: string;
|
||||
}) {
|
||||
if (typeof route.name === 'string' && LIGHT_MENU_NAMES.has(route.name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (
|
||||
route.matched?.some(
|
||||
(item) =>
|
||||
typeof item.name === 'string' && LIGHT_MENU_NAMES.has(item.name),
|
||||
)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const path = normalizePath(route.fullPath || route.path);
|
||||
return LIGHT_ROUTE_PATH_PREFIXES.some(
|
||||
(prefix) => path === prefix || path.startsWith(`${prefix}/`),
|
||||
);
|
||||
}
|
||||
|
||||
export function filterLightMenuTree<
|
||||
T extends { children?: T[]; name?: string },
|
||||
>(routes: T[]): T[] {
|
||||
|
||||
Reference in New Issue
Block a user