From 19fac9b3d61dbd646ec593693b5b932aa6c3de39 Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Sat, 21 Jun 2025 23:27:55 +0800 Subject: [PATCH] feat(auth): add protected layout with role-based access control --- .../problems/[problemId]/edit/layout.tsx | 3 +- src/app/(protected)/dashboard/page.tsx | 24 +++++++---- src/app/(protected)/layout.tsx | 15 +++++++ src/components/sidebar/admin-sidebar.tsx | 4 +- src/components/sidebar/app-sidebar.tsx | 20 +++++---- src/components/sidebar/teacher-sidebar.tsx | 42 ++++--------------- .../layouts/protected-layout.tsx | 2 +- .../user-management/components/user-table.tsx | 2 +- 8 files changed, 54 insertions(+), 58 deletions(-) create mode 100644 src/app/(protected)/layout.tsx rename src/features/{admin/ui => dashboard}/layouts/protected-layout.tsx (95%) diff --git a/src/app/(protected)/dashboard/admin/problems/[problemId]/edit/layout.tsx b/src/app/(protected)/dashboard/admin/problems/[problemId]/edit/layout.tsx index fb46c63..de77dfd 100644 --- a/src/app/(protected)/dashboard/admin/problems/[problemId]/edit/layout.tsx +++ b/src/app/(protected)/dashboard/admin/problems/[problemId]/edit/layout.tsx @@ -1,5 +1,4 @@ import { notFound } from "next/navigation"; -import { ProblemEditLayout } from "@/features/admin/ui/layouts/problem-edit-layout"; interface LayoutProps { children: React.ReactNode; @@ -13,7 +12,7 @@ const Layout = async ({ children, params }: LayoutProps) => { return notFound(); } - return {children}; + return <>{children}; }; export default Layout; diff --git a/src/app/(protected)/dashboard/page.tsx b/src/app/(protected)/dashboard/page.tsx index 397287a..b685250 100644 --- a/src/app/(protected)/dashboard/page.tsx +++ b/src/app/(protected)/dashboard/page.tsx @@ -8,6 +8,7 @@ import { BarChart3, Target, Activity, + GraduationCapIcon, } from "lucide-react"; import Link from "next/link"; import { @@ -197,21 +198,26 @@ export default async function DashboardPage() { }, ], actions: [ + { + label: "管理员管理", + href: "/dashboard/management", + icon: Target, + }, { label: "用户管理", href: "/dashboard/usermanagement/guest", icon: Users, }, + { + label: "教师管理", + href: "/dashboard/usermanagement/teacher", + icon: GraduationCapIcon, + }, { label: "题目管理", href: "/dashboard/usermanagement/problem", icon: BookOpen, }, - { - label: "管理员设置", - href: "/dashboard/management", - icon: Target, - }, ], }; case "TEACHER": @@ -240,7 +246,7 @@ export default async function DashboardPage() { ], actions: [ { - label: "学生管理", + label: "用户管理", href: "/dashboard/usermanagement/guest", icon: Users, }, @@ -250,7 +256,7 @@ export default async function DashboardPage() { icon: BookOpen, }, { - label: "统计分析", + label: "完成情况", href: "/dashboard/teacher/dashboard", icon: BarChart3, }, @@ -281,12 +287,12 @@ export default async function DashboardPage() { }, ], actions: [ - { label: "开始做题", href: "/problemset", icon: BookOpen }, { label: "我的进度", href: "/dashboard/student/dashboard", icon: TrendingUp, }, + { label: "开始做题", href: "/problemset", icon: BookOpen }, { label: "个人设置", href: "/dashboard/management", icon: Target }, ], }; @@ -361,7 +367,7 @@ export default async function DashboardPage() { 常用功能快速访问 -
+
{config.actions.map((action, index) => (