import { NavLink, Outlet } from "react-router-dom"; import { ChevronsUpDown, LogOut } from "lucide-react"; import { cn } from "@/lib/utils"; import { navForRole } from "@/lib/rbac"; import { useAuth } from "@/lib/auth"; import { Avatar, AvatarFallback, } from "@/components/ui/avatar"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; export function AppShell() { const { role, user, logout } = useAuth(); const groups = navForRole(role); // 展示文本标签(账号类型): 运营方/载体方/OPC/服务方。 // 优先按 role 映射(取自身份/端口角色, 可靠), 兜底用后端下发的 account_type_label。 const roleToLabel: Record = { operator: "运营方", carrier: "载体方", opc_member: "OPC", service: "服务方", }; const atypeLabel = (user as { account_type_label?: string })?.account_type_label; const roleLabel = roleToLabel[role ?? ""] || atypeLabel || role || "运营方"; return (
{/* 侧边栏 */} {/* 主内容 */}
当前身份: {roleLabel}
); } function UserMenu({ roleLabel, username, onLogout, }: { roleLabel: string; username: string; onLogout: () => void; }) { return ( {username} 退出登录 ); }