judge4c/src/components/sidebar/admin-sidebar.tsx

86 lines
2.4 KiB
TypeScript
Raw Normal View History

2025-06-20 12:18:13 +00:00
"use client"
import { siteConfig } from "@/config/site"
import * as React from "react"
import {
LifeBuoy,
Send,
Shield,
} from "lucide-react"
import { NavMain } from "@/components/nav-main"
import { NavSecondary } from "@/components/nav-secondary"
import { NavUser } from "@/components/nav-user"
import {
Sidebar,
SidebarContent,
SidebarFooter,
SidebarHeader,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
} from "@/components/ui/sidebar"
2025-06-21 09:44:14 +00:00
import { User } from "next-auth"
2025-06-20 12:18:13 +00:00
const adminData = {
navMain: [
{
title: "管理面板",
url: "#",
icon: Shield,
isActive: true,
items: [
2025-06-21 09:44:14 +00:00
{ title: "管理员管理", url: "/dashboard/usermanagement/admin" },
{ title: "用户管理", url: "/dashboard/usermanagement/guest" },
{ title: "教师管理", url: "/dashboard/usermanagement/teacher" },
{ title: "题目管理", url: "/dashboard/usermanagement/problem" },
2025-06-20 12:18:13 +00:00
],
},
],
navSecondary: [
{ title: "帮助", url: "/", icon: LifeBuoy },
{ title: "反馈", url: siteConfig.url.repo.github, icon: Send },
],
}
2025-06-21 09:44:14 +00:00
interface AdminSidebarProps {
user: User;
2025-06-20 12:18:13 +00:00
}
2025-06-21 09:44:14 +00:00
export function AdminSidebar({ user, ...props }: AdminSidebarProps & React.ComponentProps<typeof Sidebar>) {
const userInfo = {
name: user.name ?? "管理员",
email: user.email ?? "",
avatar: user.image ?? "/avatars/default.jpg",
};
2025-06-20 12:18:13 +00:00
return (
<Sidebar {...props}>
<SidebarHeader>
<SidebarMenu>
<SidebarMenuItem>
<SidebarMenuButton size="lg" asChild>
<a href="#">
<div className="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
<Shield className="size-4" />
</div>
<div className="grid flex-1 text-left text-sm leading-tight">
<span className="truncate font-semibold">Admin</span>
<span className="truncate text-xs"></span>
</div>
</a>
</SidebarMenuButton>
</SidebarMenuItem>
</SidebarMenu>
</SidebarHeader>
<SidebarContent>
<NavMain items={adminData.navMain} />
<NavSecondary items={adminData.navSecondary} className="mt-auto" />
</SidebarContent>
<SidebarFooter>
2025-06-21 09:44:14 +00:00
<NavUser user={userInfo} />
2025-06-20 12:18:13 +00:00
</SidebarFooter>
</Sidebar>
)
}