68 lines
1.6 KiB
TypeScript
68 lines
1.6 KiB
TypeScript
"use client"
|
|
|
|
import {
|
|
IconDashboard,
|
|
IconChartBar,
|
|
IconUsers,
|
|
IconCamera,
|
|
IconFileDescription,
|
|
IconFileAi,
|
|
IconSettings,
|
|
IconHelp,
|
|
IconSearch,
|
|
IconDatabase,
|
|
IconReport
|
|
} from "@tabler/icons-react"
|
|
import { usePathname } from "next/navigation"
|
|
import Link from "next/link"
|
|
import {
|
|
SidebarMenu,
|
|
SidebarMenuButton,
|
|
SidebarMenuItem,
|
|
} from "@/components/ui/sidebar"
|
|
|
|
// 图标映射
|
|
const iconMap = {
|
|
dashboard: IconDashboard,
|
|
chartBar: IconChartBar,
|
|
users: IconUsers,
|
|
camera: IconCamera,
|
|
fileDescription: IconFileDescription,
|
|
fileAi: IconFileAi,
|
|
settings: IconSettings,
|
|
help: IconHelp,
|
|
search: IconSearch,
|
|
database: IconDatabase,
|
|
report: IconReport,
|
|
} as const;
|
|
|
|
export function NavMainClient({
|
|
items,
|
|
}: {
|
|
items: {
|
|
title: string
|
|
url: string
|
|
iconName: string
|
|
}[]
|
|
}) {
|
|
const pathname = usePathname()
|
|
|
|
return (
|
|
<SidebarMenu>
|
|
{items.map((item) => {
|
|
const IconComponent = iconMap[item.iconName as keyof typeof iconMap];
|
|
|
|
return (
|
|
<SidebarMenuItem key={item.title}>
|
|
<Link href={item.url}>
|
|
<SidebarMenuButton tooltip={item.title} isActive={pathname === item.url}>
|
|
{IconComponent && <IconComponent />}
|
|
<span>{item.title}</span>
|
|
</SidebarMenuButton>
|
|
</Link>
|
|
</SidebarMenuItem>
|
|
);
|
|
})}
|
|
</SidebarMenu>
|
|
)
|
|
}
|