Clean lightweight admin menus
This commit is contained in:
@@ -13,6 +13,42 @@ import { useAppContextStore } from '#/store/app-context';
|
|||||||
|
|
||||||
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
|
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) {
|
function normalizeViewPath(path: string) {
|
||||||
const normalizedPath = path.replace(/^(\.\/|\.\.\/)+/, '');
|
const normalizedPath = path.replace(/^(\.\/|\.\.\/)+/, '');
|
||||||
const viewPath = normalizedPath.startsWith('/')
|
const viewPath = normalizedPath.startsWith('/')
|
||||||
@@ -58,6 +94,10 @@ function normalizeBackendRoute<T extends { component?: string; name?: string; pa
|
|||||||
return normalized;
|
return normalized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isLightMenuRoute(route: { name?: string }) {
|
||||||
|
return !route.name || lightMenuNames.has(route.name);
|
||||||
|
}
|
||||||
|
|
||||||
function filterAvailableRoutes<
|
function filterAvailableRoutes<
|
||||||
T extends {
|
T extends {
|
||||||
children?: T[];
|
children?: T[];
|
||||||
@@ -72,6 +112,7 @@ function filterAvailableRoutes<
|
|||||||
layoutMap: ComponentRecordType,
|
layoutMap: ComponentRecordType,
|
||||||
): T[] {
|
): T[] {
|
||||||
return routes
|
return routes
|
||||||
|
.filter(isLightMenuRoute)
|
||||||
.map((route) => {
|
.map((route) => {
|
||||||
const normalizedRoute = normalizeBackendRoute(route);
|
const normalizedRoute = normalizeBackendRoute(route);
|
||||||
const children = normalizedRoute.children
|
const children = normalizedRoute.children
|
||||||
|
|||||||
@@ -2,18 +2,26 @@ import type { RouteRecordRaw } from 'vue-router';
|
|||||||
|
|
||||||
const routes: RouteRecordRaw[] = [
|
const routes: RouteRecordRaw[] = [
|
||||||
{
|
{
|
||||||
|
meta: { hideInMenu: true },
|
||||||
|
name: 'AIKnowledgeLegacyRedirect',
|
||||||
path: '/ai-platform/knowledge',
|
path: '/ai-platform/knowledge',
|
||||||
redirect: '/ai-platform/knowledge-base',
|
redirect: '/ai-platform/knowledge-base',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
meta: { hideInMenu: true },
|
||||||
|
name: 'AIKnowledgeLegacyDetailRedirect',
|
||||||
path: '/ai-platform/knowledge/detail/:id',
|
path: '/ai-platform/knowledge/detail/:id',
|
||||||
redirect: (to) => `/ai-platform/knowledge-base/detail/${to.params.id}`,
|
redirect: (to) => `/ai-platform/knowledge-base/detail/${to.params.id}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
meta: { hideInMenu: true },
|
||||||
|
name: 'SubAppAIKnowledgeLegacyRedirect',
|
||||||
path: '/app/:appCode/ai-platform/knowledge',
|
path: '/app/:appCode/ai-platform/knowledge',
|
||||||
redirect: (to) => `/app/${to.params.appCode}/ai-platform/knowledge-base`,
|
redirect: (to) => `/app/${to.params.appCode}/ai-platform/knowledge-base`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
meta: { hideInMenu: true },
|
||||||
|
name: 'SubAppAIKnowledgeLegacyDetailRedirect',
|
||||||
path: '/app/:appCode/ai-platform/knowledge/detail/:id',
|
path: '/app/:appCode/ai-platform/knowledge/detail/:id',
|
||||||
redirect: (to) =>
|
redirect: (to) =>
|
||||||
`/app/${to.params.appCode}/ai-platform/knowledge-base/detail/${to.params.id}`,
|
`/app/${to.params.appCode}/ai-platform/knowledge-base/detail/${to.params.id}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user