feat(web): Home page ui upgrade
This commit is contained in:
@@ -124,56 +124,40 @@
|
||||
],
|
||||
"space": [
|
||||
{
|
||||
"id": 4,
|
||||
"id": 1,
|
||||
"parent": 0,
|
||||
"code": "dashboard",
|
||||
"label": "记忆看板",
|
||||
"i18nKey": "menu.home",
|
||||
"code": "workbench",
|
||||
"label": "workbench",
|
||||
"i18nKey": "menu.workbench",
|
||||
"path": "/",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"parent": 0,
|
||||
"code": "application",
|
||||
"label": "应用管理",
|
||||
"i18nKey": "menu.applicationManagement",
|
||||
"path": "/application",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"parent": 0,
|
||||
"code": "knowledge",
|
||||
"label": "知识库",
|
||||
"i18nKey": "menu.knowledgeManagement",
|
||||
"path": "/knowledge-base",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"type": "group",
|
||||
"subs": [
|
||||
{
|
||||
"id": 61,
|
||||
"parent": 6,
|
||||
"code": "knowledgePrivate",
|
||||
"label": "Private",
|
||||
"i18nKey": "menu.knowledgePrivate",
|
||||
"path": "/knowledge-base/:knowledgeBaseId/private",
|
||||
"id": 11,
|
||||
"parent": 1,
|
||||
"code": "dashboard",
|
||||
"label": "记忆看板",
|
||||
"i18nKey": "menu.home",
|
||||
"path": "/",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"parent": 1,
|
||||
"code": "application",
|
||||
"label": "应用管理",
|
||||
"i18nKey": "menu.applicationManagement",
|
||||
"path": "/application",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
@@ -181,261 +165,338 @@
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 62,
|
||||
"parent": 6,
|
||||
"code": "knowledgeShare",
|
||||
"label": "Share",
|
||||
"i18nKey": "menu.knowledgeShare",
|
||||
"path": "/knowledge-base/:knowledgeBaseId/share",
|
||||
"id": 13,
|
||||
"parent": 1,
|
||||
"code": "knowledge",
|
||||
"label": "知识库",
|
||||
"i18nKey": "menu.knowledgeManagement",
|
||||
"path": "/knowledge-base",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 63,
|
||||
"parent": 6,
|
||||
"code": "knowledgeCreateDataset",
|
||||
"label": "CreateDataset",
|
||||
"i18nKey": "menu.knowledgeCreateDataset",
|
||||
"path": "/knowledge-base/:knowledgeBaseId/create-dataset",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 64,
|
||||
"parent": 6,
|
||||
"code": "knowledgeDocumentDetails",
|
||||
"label": "DocumentDetails",
|
||||
"i18nKey": "menu.knowledgeDocumentDetails",
|
||||
"path": "/knowledge-base/:knowledgeBaseId/DocumentDetails",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"parent": 0,
|
||||
"code": "memory",
|
||||
"label": "记忆管理",
|
||||
"i18nKey": "menu.memoryManagement",
|
||||
"path": "/memory",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": [
|
||||
{
|
||||
"id": 71,
|
||||
"parent": 7,
|
||||
"code": "forgettingEngine",
|
||||
"label": "遗忘引擎",
|
||||
"i18nKey": "menu.forgettingEngine",
|
||||
"path": "/forgetting-engine/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 72,
|
||||
"parent": 7,
|
||||
"code": "memoryExtractionEngine",
|
||||
"label": "记忆萃取引擎",
|
||||
"i18nKey": "menu.memoryExtractionEngine",
|
||||
"path": "/memory-extraction-engine/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 72,
|
||||
"parent": 7,
|
||||
"code": "emotionEngine",
|
||||
"label": "情感引擎",
|
||||
"i18nKey": "menu.emotionEngine",
|
||||
"path": "/emotion-engine/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 72,
|
||||
"parent": 7,
|
||||
"code": "selfReflectionEngine",
|
||||
"label": "反思引擎",
|
||||
"i18nKey": "menu.selfReflectionEngine",
|
||||
"path": "/reflection-engine/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"parent": 0,
|
||||
"code": "userMemory",
|
||||
"label": "",
|
||||
"i18nKey": "menu.userMemory",
|
||||
"path": "/user-memory",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 1,
|
||||
"menuDesc": "管理用户记忆",
|
||||
"subs": [
|
||||
{
|
||||
"id": 81,
|
||||
"parent": 8,
|
||||
"code": "userMemoryDetail",
|
||||
"label": "记忆详情",
|
||||
"i18nKey": "menu.userMemoryDetail",
|
||||
"path": "/user-memory/neo4j/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 2,
|
||||
"sort": 0,
|
||||
"subs": [
|
||||
{
|
||||
"id": 811,
|
||||
"parent": 81,
|
||||
"code": "statementDetail",
|
||||
"label": "记忆详情",
|
||||
"i18nKey": "menu.statementDetail",
|
||||
"path": "/statement/:id",
|
||||
"id": 131,
|
||||
"parent": 13,
|
||||
"code": "knowledgePrivate",
|
||||
"label": "Private",
|
||||
"i18nKey": "menu.knowledgePrivate",
|
||||
"path": "/knowledge-base/:knowledgeBaseId/private",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 132,
|
||||
"parent": 13,
|
||||
"code": "knowledgeShare",
|
||||
"label": "Share",
|
||||
"i18nKey": "menu.knowledgeShare",
|
||||
"path": "/knowledge-base/:knowledgeBaseId/share",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 133,
|
||||
"parent": 13,
|
||||
"code": "knowledgeCreateDataset",
|
||||
"label": "CreateDataset",
|
||||
"i18nKey": "menu.knowledgeCreateDataset",
|
||||
"path": "/knowledge-base/:knowledgeBaseId/create-dataset",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 134,
|
||||
"parent": 13,
|
||||
"code": "knowledgeDocumentDetails",
|
||||
"label": "DocumentDetails",
|
||||
"i18nKey": "menu.knowledgeDocumentDetails",
|
||||
"path": "/knowledge-base/:knowledgeBaseId/DocumentDetails",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"parent": 1,
|
||||
"code": "prompt",
|
||||
"label": "提示词",
|
||||
"i18nKey": "menu.prompt",
|
||||
"path": "/prompt",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": [
|
||||
{
|
||||
"id": 141,
|
||||
"parent": 14,
|
||||
"code": "promptHistory",
|
||||
"label": "promptHistory",
|
||||
"i18nKey": "menu.promptHistory",
|
||||
"path": "/prompt/history",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 3,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"parent": 0,
|
||||
"code": "memoryRelated",
|
||||
"label": "memoryRelated",
|
||||
"i18nKey": "menu.memoryRelated",
|
||||
"path": "/",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"type": "group",
|
||||
"subs": [
|
||||
{
|
||||
"id": 21,
|
||||
"parent": 2,
|
||||
"code": "memory",
|
||||
"label": "记忆管理",
|
||||
"i18nKey": "menu.memoryManagement",
|
||||
"path": "/memory",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": [
|
||||
{
|
||||
"id": 211,
|
||||
"parent": 21,
|
||||
"code": "forgettingEngine",
|
||||
"label": "遗忘引擎",
|
||||
"i18nKey": "menu.forgettingEngine",
|
||||
"path": "/forgetting-engine/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 212,
|
||||
"parent": 21,
|
||||
"code": "memoryExtractionEngine",
|
||||
"label": "记忆萃取引擎",
|
||||
"i18nKey": "menu.memoryExtractionEngine",
|
||||
"path": "/memory-extraction-engine/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 213,
|
||||
"parent": 21,
|
||||
"code": "emotionEngine",
|
||||
"label": "情感引擎",
|
||||
"i18nKey": "menu.emotionEngine",
|
||||
"path": "/emotion-engine/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 214,
|
||||
"parent": 21,
|
||||
"code": "selfReflectionEngine",
|
||||
"label": "反思引擎",
|
||||
"i18nKey": "menu.selfReflectionEngine",
|
||||
"path": "/reflection-engine/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 81,
|
||||
"parent": 8,
|
||||
"code": "userMemoryDetail",
|
||||
"label": "记忆详情",
|
||||
"i18nKey": "menu.userMemoryDetail",
|
||||
"path": "/user-memory/:id",
|
||||
"id": 22,
|
||||
"parent": 2,
|
||||
"code": "userMemory",
|
||||
"label": "",
|
||||
"i18nKey": "menu.userMemory",
|
||||
"path": "/user-memory",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 2,
|
||||
"sort": 0
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 1,
|
||||
"menuDesc": "管理用户记忆",
|
||||
"subs": [
|
||||
{
|
||||
"id": 221,
|
||||
"parent": 22,
|
||||
"code": "userMemoryDetail",
|
||||
"label": "记忆详情",
|
||||
"i18nKey": "menu.userMemoryDetail",
|
||||
"path": "/user-memory/neo4j/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 2,
|
||||
"sort": 0,
|
||||
"subs": [
|
||||
{
|
||||
"id": 2211,
|
||||
"parent": 221,
|
||||
"code": "statementDetail",
|
||||
"label": "记忆详情",
|
||||
"i18nKey": "menu.statementDetail",
|
||||
"path": "/statement/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 3,
|
||||
"sort": 0,
|
||||
"subs": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 222,
|
||||
"parent": 22,
|
||||
"code": "userMemoryDetail",
|
||||
"label": "记忆详情",
|
||||
"i18nKey": "menu.userMemoryDetail",
|
||||
"path": "/user-memory/:id",
|
||||
"enable": true,
|
||||
"display": false,
|
||||
"level": 2,
|
||||
"sort": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 23,
|
||||
"parent": 2,
|
||||
"code": "ontology",
|
||||
"label": "本体工程",
|
||||
"i18nKey": "menu.ontology",
|
||||
"path": "/ontology",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
"parent": 2,
|
||||
"code": "memoryConversation",
|
||||
"label": "记忆验证",
|
||||
"i18nKey": "menu.memoryConversation",
|
||||
"path": "/memory-conversation",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"id": 3,
|
||||
"parent": 0,
|
||||
"code": "ontology",
|
||||
"label": "本体工程",
|
||||
"i18nKey": "menu.ontology",
|
||||
"path": "/ontology",
|
||||
"code": "advancedSettings",
|
||||
"label": "advancedSettings",
|
||||
"i18nKey": "menu.advancedSettings",
|
||||
"path": "/",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"parent": 0,
|
||||
"code": "memoryConversation",
|
||||
"label": "记忆验证",
|
||||
"i18nKey": "menu.memoryConversation",
|
||||
"path": "/memory-conversation",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"parent": 0,
|
||||
"code": "apiKey",
|
||||
"label": "API KEY管理",
|
||||
"i18nKey": "menu.apiKeyManagement",
|
||||
"path": "/api-key",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"parent": 0,
|
||||
"code": "prompt",
|
||||
"label": "提示词",
|
||||
"i18nKey": "menu.prompt",
|
||||
"path": "/prompt",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"parent": 0,
|
||||
"code": "member",
|
||||
"label": "成员管理",
|
||||
"i18nKey": "menu.memberManagement",
|
||||
"path": "/member",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"parent": 0,
|
||||
"code": "spaceConfig",
|
||||
"label": "空间配置",
|
||||
"i18nKey": "menu.spaceConfig",
|
||||
"path": "/space-config",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
"type": "group",
|
||||
"subs": [
|
||||
{
|
||||
"id": 31,
|
||||
"parent": 3,
|
||||
"code": "apiKey",
|
||||
"label": "API KEY管理",
|
||||
"i18nKey": "menu.apiKeyManagement",
|
||||
"path": "/api-key",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 32,
|
||||
"parent": 3,
|
||||
"code": "member",
|
||||
"label": "成员管理",
|
||||
"i18nKey": "menu.memberManagement",
|
||||
"path": "/member",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
},
|
||||
{
|
||||
"id": 33,
|
||||
"parent": 3,
|
||||
"code": "spaceConfig",
|
||||
"label": "空间配置",
|
||||
"i18nKey": "menu.spaceConfig",
|
||||
"path": "/space-config",
|
||||
"enable": true,
|
||||
"display": true,
|
||||
"level": 1,
|
||||
"sort": 0,
|
||||
"icon": null,
|
||||
"iconActive": null,
|
||||
"subs": null
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
/*
|
||||
* @Author: ZhaoYing
|
||||
* @Date: 2026-02-02 16:33:34
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-02-02 16:33:34
|
||||
* @Last Modified by: ZhaoYing
|
||||
* @Last Modified time: 2026-02-04 10:31:14
|
||||
*/
|
||||
/**
|
||||
* Menu Store
|
||||
@@ -42,6 +42,7 @@ export interface MenuItem {
|
||||
master?: string | null;
|
||||
disposable?: boolean;
|
||||
appSystem?: string | null;
|
||||
type?: 'group' | string;
|
||||
subs?: MenuItem[] | null;
|
||||
onClick?: (e?: React.MouseEvent) => void | boolean;
|
||||
}
|
||||
@@ -89,20 +90,27 @@ export const useMenu = create<MenuState>((set, get) => ({
|
||||
const { allMenus } = get()
|
||||
const menus = allMenus[source] || []
|
||||
let result: MenuItem[] = []
|
||||
|
||||
console.log('updateBreadcrumbs paths:', paths);
|
||||
|
||||
|
||||
/** Flatten group menus so top-level items are always real menu entries */
|
||||
const flatMenus = menus.flatMap(m => m.type === 'group' ? (m.subs || []) : [m]);
|
||||
|
||||
const findById = (list: MenuItem[], id: string) => list.find(m => `${m.id}` === id);
|
||||
/** Find menu by id in both original menus and flatMenus (handles group ids) */
|
||||
const findMenuById = (id: string) => findById(menus, id) || findById(flatMenus, id);
|
||||
const pathMatches = (pattern: string, path: string) => {
|
||||
const n = pattern[0] !== '/' ? '/' + pattern : pattern;
|
||||
if (n === path) return true;
|
||||
if (n.includes(':')) return new RegExp('^' + n.replace(/:[\w-]+/g, '[^/]+') + '$').test(path);
|
||||
return false;
|
||||
};
|
||||
|
||||
if (paths.length === 3) {
|
||||
/** Three-level menu: [subSubPath, subId, menuId] */
|
||||
const menuId = paths[2];
|
||||
const subId = paths[1];
|
||||
const subSubPath = paths[0];
|
||||
|
||||
const matchedMenu = menus.find(menu => `${menu.id}` === menuId);
|
||||
if (matchedMenu && matchedMenu.subs) {
|
||||
const matchedSub = matchedMenu.subs.find(sub => `${sub.id}` === subId);
|
||||
if (matchedSub && matchedSub.subs) {
|
||||
const matchedSubSub = matchedSub.subs.find(subSub => subSub.path === subSubPath);
|
||||
/** Three-level: [subSubPath, subId, menuId] */
|
||||
const matchedMenu = findMenuById(paths[2]);
|
||||
if (matchedMenu?.subs) {
|
||||
const matchedSub = findById(matchedMenu.subs, paths[1]);
|
||||
if (matchedSub?.subs) {
|
||||
const matchedSubSub = matchedSub.subs.find(s => s.path === paths[0] || pathMatches(s.path || '', paths[0]));
|
||||
if (matchedSubSub) {
|
||||
result = [
|
||||
{ ...matchedMenu, subs: null },
|
||||
@@ -113,23 +121,16 @@ export const useMenu = create<MenuState>((set, get) => ({
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/** Original logic for one-level and two-level menus */
|
||||
const matchedMenu: MenuItem | undefined = menus.find(menu => menu.path === paths[paths.length - 1] || `${menu.id}` === paths[1]);
|
||||
|
||||
const matchedMenu = flatMenus.find(m => m.path === paths[0] || `${m.id}` === paths[1]);
|
||||
if (matchedMenu) {
|
||||
let matchedSubMenu: MenuItem | undefined = undefined;
|
||||
if (paths.length > 1 && matchedMenu?.subs?.length) {
|
||||
matchedSubMenu = matchedMenu.subs.find(menu => menu.path === paths[0]);
|
||||
let matchedSubMenu: MenuItem | undefined;
|
||||
if (paths.length > 1 && matchedMenu.subs?.length) {
|
||||
matchedSubMenu = matchedMenu.subs.find(m => m.path === paths[0]);
|
||||
}
|
||||
result = [
|
||||
{ ...matchedMenu, subs: null },
|
||||
matchedSubMenu
|
||||
].filter(item => item !== undefined) as MenuItem[]
|
||||
} else {
|
||||
result = [] as MenuItem[]
|
||||
result = [{ ...matchedMenu, subs: null }, matchedSubMenu].filter(Boolean) as MenuItem[];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const allBreadcrumbs = { ...get().allBreadcrumbs, [source]: result }
|
||||
set({ allBreadcrumbs })
|
||||
localStorage.setItem('breadcrumbs', JSON.stringify(allBreadcrumbs))
|
||||
|
||||
Reference in New Issue
Block a user