import { ROUTES } from '@/routes'; import type { BreadcrumbEntry } from './nav-config'; /** 角色模块下的子路由(新建 / 编辑器)不在 nav-config 的菜单项里,这里补齐面包屑 */ export function getRoleSectionTrail(pathname: string): BreadcrumbEntry[] | null { if (pathname === ROUTES.system.roleNew) { return [ { key: 'home', label: '工作台', path: ROUTES.home }, { key: 'system', label: '管理中心' }, { key: 'roles', label: '角色权限', path: ROUTES.system.roles }, { key: 'role-new', label: '新建角色' }, ]; } if (/^\/system\/roles\/[^/]+$/.test(pathname)) { return [ { key: 'home', label: '工作台', path: ROUTES.home }, { key: 'system', label: '管理中心' }, { key: 'roles', label: '角色权限', path: ROUTES.system.roles }, { key: 'role-detail', label: '角色编辑' }, ]; } return null; } /** * 用户模块下的子路由(新建 / 详情)不在 nav-config 的菜单项里, * 这里补齐面包屑:工作台 / 管理中心 / 用户与组织 / 当前页。 */ export function getUserSectionTrail(pathname: string): BreadcrumbEntry[] | null { if (pathname === ROUTES.system.userNew) { return [ { key: 'home', label: '工作台', path: ROUTES.home }, { key: 'system', label: '管理中心' }, { key: 'users', label: '用户与组织', path: ROUTES.system.users }, { key: 'user-new', label: '新建用户' }, ]; } if (/^\/system\/users\/[^/]+$/.test(pathname)) { return [ { key: 'home', label: '工作台', path: ROUTES.home }, { key: 'system', label: '管理中心' }, { key: 'users', label: '用户与组织', path: ROUTES.system.users }, { key: 'user-detail', label: '成员详情' }, ]; } return null; }