diff --git a/src/store/modules/route/shared.ts b/src/store/modules/route/shared.ts index c9cfa1024..e7a6c7f9c 100644 --- a/src/store/modules/route/shared.ts +++ b/src/store/modules/route/shared.ts @@ -281,15 +281,25 @@ export function getBreadcrumbsByRoute( const key = route.name as string; const activeKey = route.meta?.activeMenu; - const menuKey = activeKey || key; - for (const menu of menus) { - if (menu.key === menuKey) { - const breadcrumbMenu = menuKey !== activeKey ? menu : getGlobalMenuByBaseRoute(route); - + if (menu.key === key) { + const breadcrumbMenu = menu; return [transformMenuToBreadcrumb(breadcrumbMenu)]; } + if (menu.key === activeKey) { + const ROUTE_DEGREE_SPLITTER = '_'; + + const parentKey = key.split(ROUTE_DEGREE_SPLITTER).slice(0, -1).join(ROUTE_DEGREE_SPLITTER); + + const breadcrumbMenu = getGlobalMenuByBaseRoute(route); + if (parentKey !== activeKey) { + return [transformMenuToBreadcrumb(breadcrumbMenu)]; + } + + return [transformMenuToBreadcrumb(menu), transformMenuToBreadcrumb(breadcrumbMenu)]; + } + if (menu.children?.length) { const result = getBreadcrumbsByRoute(route, menu.children); if (result.length > 0) {