Skip to content

Commit 79b2a28

Browse files
committed
fix(projects): fix breadcrumb when activeMenu is parent menu. fixed #589
1 parent 531bfaf commit 79b2a28

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/store/modules/route/shared.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,15 +281,25 @@ export function getBreadcrumbsByRoute(
281281
const key = route.name as string;
282282
const activeKey = route.meta?.activeMenu;
283283

284-
const menuKey = activeKey || key;
285-
286284
for (const menu of menus) {
287-
if (menu.key === menuKey) {
288-
const breadcrumbMenu = menuKey !== activeKey ? menu : getGlobalMenuByBaseRoute(route);
289-
285+
if (menu.key === key) {
286+
const breadcrumbMenu = menu;
290287
return [transformMenuToBreadcrumb(breadcrumbMenu)];
291288
}
292289

290+
if (menu.key === activeKey) {
291+
const ROUTE_DEGREE_SPLITTER = '_';
292+
293+
const parentKey = key.split(ROUTE_DEGREE_SPLITTER).slice(0, -1).join(ROUTE_DEGREE_SPLITTER);
294+
295+
const breadcrumbMenu = getGlobalMenuByBaseRoute(route);
296+
if (parentKey !== activeKey) {
297+
return [transformMenuToBreadcrumb(breadcrumbMenu)];
298+
}
299+
300+
return [transformMenuToBreadcrumb(menu), transformMenuToBreadcrumb(breadcrumbMenu)];
301+
}
302+
293303
if (menu.children?.length) {
294304
const result = getBreadcrumbsByRoute(route, menu.children);
295305
if (result.length > 0) {

0 commit comments

Comments
 (0)