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

84 lines
2.5 KiB
TypeScript
Raw Normal View History

2025-06-21 15:19:49 +00:00
"use client";
2025-06-20 12:18:13 +00:00
2025-06-21 15:19:49 +00:00
import * as React from "react";
2025-06-20 12:18:13 +00:00
import {
Sidebar,
SidebarContent,
SidebarFooter,
SidebarHeader,
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
2025-06-21 15:19:49 +00:00
} from "@/components/ui/sidebar";
import { User } from "next-auth";
import { siteConfig } from "@/config/site";
import { NavMain } from "@/components/nav-main";
import { NavUser } from "@/components/nav-user";
import { LifeBuoy, Send, Shield } from "lucide-react";
import { NavSecondary } from "@/components/nav-secondary";
2025-06-20 12:18:13 +00:00
const adminData = {
navMain: [
{
title: "管理面板",
2025-06-21 15:19:49 +00:00
url: "/dashboard",
2025-06-20 12:18:13 +00:00
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: `${siteConfig.url.repo.github}/issues`, icon: LifeBuoy },
{ title: "反馈", url: `${siteConfig.url.repo.github}/pulls`, icon: Send },
2025-06-20 12:18:13 +00:00
],
2025-06-21 15:19:49 +00:00
};
2025-06-20 12:18:13 +00:00
2025-06-21 09:44:14 +00:00
interface AdminSidebarProps {
user: User;
2025-06-20 12:18:13 +00:00
}
2025-06-21 15:19:49 +00:00
export function AdminSidebar({
user,
...props
}: AdminSidebarProps & React.ComponentProps<typeof Sidebar>) {
2025-06-21 09:44:14 +00:00
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>
2025-06-21 15:19:49 +00:00
);
2025-06-20 12:18:13 +00:00
}