fix(menu): подсветка родительского пункта на detail-страницах
Refs EventHub/EventHubFrontAdmin#7 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -52,3 +52,18 @@ export function filterMenuByRole<T extends { roles?: AdminRole[] }>(
|
||||
): T[] {
|
||||
return items.filter((item) => !item.roles || (role && item.roles.includes(role as AdminRole)));
|
||||
}
|
||||
|
||||
/** Ключ пункта меню для detail-маршрутов (/users/:id → /users). */
|
||||
export function getMenuSelectedKey(pathname: string): string {
|
||||
if (MENU_ITEMS.some((item) => item.key === pathname)) {
|
||||
return pathname;
|
||||
}
|
||||
const segment = pathname.split('/').filter(Boolean)[0];
|
||||
if (segment) {
|
||||
const parent = `/${segment}`;
|
||||
if (MENU_ITEMS.some((item) => item.key === parent)) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
return pathname;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user