部分样式调整

This commit is contained in:
xiaozhu
2026-08-31 11:10:49 +08:00
parent 9badd3597f
commit cc38bb1575
3 changed files with 71 additions and 23 deletions
@@ -21,6 +21,42 @@ export type NavigationItem = {
children?: NavigationItem[];
};
export function pathForPage(page: ActivePage): string {
if (page === "home") return "/workbench";
return `/${page}`;
}
function normalizePath(pathname: string): string {
const trimmed = pathname.replace(/\/+$/, "");
return trimmed || "/";
}
/** 根据当前 pathname 解析顶栏标题:二级菜单显示子项名称,一级菜单显示自身名称。 */
export function pageTitleFromPath(pathname: string): string {
const path = normalizePath(pathname);
for (const item of navigation) {
if (item.children) {
for (const child of item.children) {
const childPath =
child.activePath ?? `${pathForPage(child.page)}/${child.sub}`;
if (path === childPath) {
return child.label;
}
}
}
}
for (const item of navigation) {
const itemPath = item.activePath ?? pathForPage(item.page);
if (path === itemPath) {
return item.label;
}
}
return "工作台";
}
export const navigation: NavigationItem[] = [
{ label: "工作台", icon: Home, page: "home", permission: "dashboard:view" },
{ label: "构建脚本", icon: Code, page: "scripts", permission: "script:view" },