feat: 统一管理端导航为后端下发菜单,移除本地权限过滤

This commit is contained in:
2026-05-19 09:34:52 +08:00
parent 1b1dfc92ab
commit d625c59393
8 changed files with 57 additions and 179 deletions

View File

@@ -11,7 +11,8 @@ import {
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";
import { adminShellNavItems, ADMIN_BASE } from "@/modules/_config/admin-nav";
import { ADMIN_BASE } from "@/modules/_config/admin-nav";
import { useAdminProfile } from "@/stores/admin-session";
import React from "react";
const DRAW_ROUTE_LABELS: Record<string, string> = {
@@ -36,6 +37,8 @@ type BreadcrumbCrumb = {
export function AdminBreadcrumb() {
const { t } = useTranslation(["common", "dashboard", "reports", "audit", "config", "draws"]);
const pathname = usePathname();
const profile = useAdminProfile();
const navItems = profile?.navigation ?? [];
// Split the current path into segments.
const segments = pathname.split("/").filter(Boolean);
@@ -52,7 +55,7 @@ export function AdminBreadcrumb() {
if (pathname !== ADMIN_BASE) {
const businessSegment = segments[1];
if (businessSegment) {
const navItem = adminShellNavItems.find((item) => {
const navItem = navItems.find((item) => {
return item.segment === businessSegment || item.href.includes(businessSegment);
});
@@ -70,6 +73,12 @@ export function AdminBreadcrumb() {
href: navItem.href,
isCurrent: pathname === navItem.href || segments.length === 2,
});
} else {
breadcrumbs.push({
label: titleCase(businessSegment),
href: `${ADMIN_BASE}/${businessSegment}`,
isCurrent: segments.length === 2,
});
}
if (segments.length > 2) {