Clean lightweight admin menus

This commit is contained in:
2026-06-10 15:59:52 +08:00
parent 7c00b81934
commit 58f889b6c9
2 changed files with 49 additions and 0 deletions
+41
View File
@@ -13,6 +13,42 @@ import { useAppContextStore } from '#/store/app-context';
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
const lightMenuNames = new Set([
'AIAgent',
'AIKnowledgeDetail',
'AIPlatform',
'AIWorkflow',
'AIWorkflowRuns',
'AnnouncementList',
'AnnouncementManage',
'Application',
'Codex',
'ControlCenter',
'FileManager',
'KnowledgeBase',
'LoginLog',
'Message',
'MessageList',
'OrgNode',
'StartChat',
'SubAppAIAgentEditor',
'SubAppAIKnowledgeDetail',
'SubAppAIWorkflowEditor',
'SubAppAIWorkflowRuns',
'SystemConfigManager',
'SystemDept',
'SystemDict',
'SystemManagement',
'SystemMenu',
'SystemPermission',
'SystemPost',
'SystemRole',
'UIConfigManager',
'UserManagement',
'userCenter',
'userSettings',
]);
function normalizeViewPath(path: string) {
const normalizedPath = path.replace(/^(\.\/|\.\.\/)+/, '');
const viewPath = normalizedPath.startsWith('/')
@@ -58,6 +94,10 @@ function normalizeBackendRoute<T extends { component?: string; name?: string; pa
return normalized;
}
function isLightMenuRoute(route: { name?: string }) {
return !route.name || lightMenuNames.has(route.name);
}
function filterAvailableRoutes<
T extends {
children?: T[];
@@ -72,6 +112,7 @@ function filterAvailableRoutes<
layoutMap: ComponentRecordType,
): T[] {
return routes
.filter(isLightMenuRoute)
.map((route) => {
const normalizedRoute = normalizeBackendRoute(route);
const children = normalizedRoute.children
@@ -2,18 +2,26 @@ import type { RouteRecordRaw } from 'vue-router';
const routes: RouteRecordRaw[] = [
{
meta: { hideInMenu: true },
name: 'AIKnowledgeLegacyRedirect',
path: '/ai-platform/knowledge',
redirect: '/ai-platform/knowledge-base',
},
{
meta: { hideInMenu: true },
name: 'AIKnowledgeLegacyDetailRedirect',
path: '/ai-platform/knowledge/detail/:id',
redirect: (to) => `/ai-platform/knowledge-base/detail/${to.params.id}`,
},
{
meta: { hideInMenu: true },
name: 'SubAppAIKnowledgeLegacyRedirect',
path: '/app/:appCode/ai-platform/knowledge',
redirect: (to) => `/app/${to.params.appCode}/ai-platform/knowledge-base`,
},
{
meta: { hideInMenu: true },
name: 'SubAppAIKnowledgeLegacyDetailRedirect',
path: '/app/:appCode/ai-platform/knowledge/detail/:id',
redirect: (to) =>
`/app/${to.params.appCode}/ai-platform/knowledge-base/detail/${to.params.id}`,