- 新增 acl.ts 工具:isSuperAdmin/SUPER_ADMIN;utils.ts 加 maskPhone - 侧边栏按角色过滤:系统管理菜单仅超管可见 - /rbac 路由服务端拦截:非超管访问重定向首页 - 客户列表:业务员手机号脱敏(中间5位星号)、删除按钮隐藏、新增查看按钮 - 删除服务端校验:仅超管可执行 - 新增 customer-view.tsx 查看弹窗,展示完整商户信息(含完整手机号) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
71 lines
2.4 KiB
TypeScript
71 lines
2.4 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { usePathname } from "next/navigation";
|
|
import { cn } from "@/lib/utils";
|
|
import { copyright } from "@/lib/brand";
|
|
import { BrandLogo } from "./brand-logo";
|
|
import { navSections, activeHref } from "./nav";
|
|
import { useSidebar } from "./sidebar-context";
|
|
|
|
export function Sidebar({ isSuperAdmin }: { isSuperAdmin: boolean }) {
|
|
const pathname = usePathname();
|
|
const active = activeHref(pathname);
|
|
const { collapsed } = useSidebar();
|
|
const sections = navSections.filter((s) => !s.superAdminOnly || isSuperAdmin);
|
|
|
|
return (
|
|
<aside
|
|
className={cn(
|
|
"shrink-0 overflow-hidden transition-[width] duration-200 ease-in-out",
|
|
collapsed ? "w-0" : "w-60"
|
|
)}
|
|
>
|
|
{/* 固定宽度内容容器:折叠时被外层裁剪,形成平滑滑动而非挤压 */}
|
|
<div className="flex h-full w-60 flex-col bg-[var(--color-sidebar)] text-[var(--color-sidebar-foreground)]">
|
|
{/* 品牌 */}
|
|
<div className="flex h-16 items-center px-5">
|
|
<Link href="/">
|
|
<BrandLogo size={36} invert />
|
|
</Link>
|
|
</div>
|
|
|
|
<nav className="flex-1 space-y-6 overflow-y-auto px-3 py-4">
|
|
{sections.map((section) => (
|
|
<div key={section.title}>
|
|
<div className="px-3 pb-2 text-[11px] font-medium uppercase tracking-wider text-[var(--color-sidebar-muted)]">
|
|
{section.title}
|
|
</div>
|
|
<div className="space-y-1">
|
|
{section.items.map((item) => {
|
|
const Icon = item.icon;
|
|
const isActive = active === item.href;
|
|
return (
|
|
<Link
|
|
key={item.href}
|
|
href={item.href}
|
|
className={cn(
|
|
"flex items-center gap-3 rounded-lg px-3 py-2 text-sm transition-colors",
|
|
isActive
|
|
? "bg-[var(--color-primary)] text-white shadow-sm"
|
|
: "text-[var(--color-sidebar-muted)] hover:bg-[var(--color-sidebar-hover)] hover:text-white"
|
|
)}
|
|
>
|
|
<Icon className="h-[18px] w-[18px]" />
|
|
{item.label}
|
|
</Link>
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
))}
|
|
</nav>
|
|
|
|
<div className="px-5 py-4 text-[11px] text-[var(--color-sidebar-muted)]">
|
|
{copyright()}
|
|
</div>
|
|
</div>
|
|
</aside>
|
|
);
|
|
}
|