Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): fix breadcrumb when activeMenu is parent menu #25 #30

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/store/modules/route/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,9 @@ 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)]
}
Expand All @@ -296,6 +294,19 @@ export function getBreadcrumbsByRoute(
return [transformMenuToBreadcrumb(menu), ...result]
}
}

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)]
}
}

return []
Expand Down
Loading