## 新增 - 创建 /admin/ai-settings 统一配置页(AiProviderSettingsCard + AiUsageDashboard) - admin 侧边栏新增"AI 配置"菜单项(权限 AI_CONFIGURE,图标 Sparkles) - 新增 deleteAiProvider 数据访问层(事务删除 + 自动转移默认) - 新增 deleteAiProviderAction Server Action(Zod 校验 + 权限校验) - AiProviderSettingsCard 新增删除按钮(AlertDialog 确认 + destructive 变体) - 新增 i18n 翻译键(delete/deleteConfirm/deleteSuccess 等,zh-CN + en) ## 移除 - 从 /settings 移除 AI 标签页(原 VALID_TABS 含 "ai",现仅 4 标签页) - 从考试页面移除 AI 配置弹窗(Dialog + AiProviderSettingsCard 内嵌) - 从 ai-provider-selector.tsx 移除配置弹窗(managePanel/manageOpen props) - 移除 settings-view.tsx 中 canConfigureAi 逻辑和未使用 import ## 变更 - 考试页面"管理"按钮改为 Link 跳转到 /admin/ai-settings - ai-provider-selector.tsx"管理"按钮改为 Link 跳转到 /admin/ai-settings - exam-form.tsx 移除 providerDialogOpen/providerDialogKey 状态 - 修正架构文档 004 中 Action 命名(getAiProvidersAction → getAiProviderSummaries 等) ## 架构文档同步 - 004 更新 settings 模块章节(V3 标记/修正 Action 名称/新增 deleteAiProvider) - 005 新增 deleteAiProviderAction 节点 + /admin/ai-settings 路由
481 lines
13 KiB
TypeScript
481 lines
13 KiB
TypeScript
import {
|
||
BookOpen,
|
||
Calendar,
|
||
CalendarRange,
|
||
LayoutDashboard,
|
||
Settings,
|
||
Users,
|
||
Shield,
|
||
FileQuestion,
|
||
ClipboardList,
|
||
Library,
|
||
PenTool,
|
||
Briefcase,
|
||
ScrollText,
|
||
Megaphone,
|
||
GraduationCap,
|
||
Mail,
|
||
CalendarCheck,
|
||
CalendarClock,
|
||
Stethoscope,
|
||
BookMarked,
|
||
BookCopy,
|
||
Files,
|
||
BookX,
|
||
Sparkles,
|
||
} from "lucide-react"
|
||
import type { LucideIcon } from "lucide-react"
|
||
import { Permissions } from "@/shared/types/permissions"
|
||
import type { Permission, Role } from "@/shared/types/permissions"
|
||
|
||
export type { Role }
|
||
|
||
export type NavItem = {
|
||
title: string
|
||
icon: LucideIcon
|
||
href: string
|
||
permission?: Permission
|
||
items?: { title: string; href: string; permission?: Permission }[]
|
||
}
|
||
|
||
/**
|
||
* 公共导航项:所有已登录用户均可访问的功能模块。
|
||
* 通过权限点(permission)控制可见性,新增角色只需在 NAV_CONFIG 中引用这些公共项,
|
||
* 无需复制粘贴。符合"配置驱动设计"和"严禁 role === 'xxx' 硬编码"的规则。
|
||
*/
|
||
const COMMON_NAV_ITEMS: NavItem[] = [
|
||
{
|
||
title: "Announcements",
|
||
icon: Megaphone,
|
||
href: "/announcements",
|
||
permission: Permissions.ANNOUNCEMENT_READ,
|
||
},
|
||
{
|
||
title: "Messages",
|
||
icon: Mail,
|
||
href: "/messages",
|
||
permission: Permissions.MESSAGE_READ,
|
||
},
|
||
]
|
||
|
||
export const NAV_CONFIG: Partial<Record<Role, NavItem[]>> = {
|
||
admin: [
|
||
{
|
||
title: "Dashboard",
|
||
icon: LayoutDashboard,
|
||
href: "/admin/dashboard",
|
||
permission: Permissions.SCHOOL_MANAGE,
|
||
},
|
||
{
|
||
title: "School Management",
|
||
icon: Shield,
|
||
href: "/admin/school",
|
||
permission: Permissions.SCHOOL_MANAGE,
|
||
items: [
|
||
{ title: "Schools", href: "/admin/school/schools" },
|
||
{ title: "Grades", href: "/admin/school/grades" },
|
||
{ title: "Grade Insights", href: "/admin/school/grades/insights" },
|
||
{ title: "Departments", href: "/admin/school/departments" },
|
||
{ title: "Classes", href: "/admin/school/classes" },
|
||
{ title: "Academic Year", href: "/admin/school/academic-year" },
|
||
]
|
||
},
|
||
{
|
||
title: "Users",
|
||
icon: Users,
|
||
href: "/admin/users",
|
||
permission: Permissions.USER_MANAGE,
|
||
items: [
|
||
{ title: "User List", href: "/admin/users" },
|
||
{ title: "Import Users", href: "/admin/users/import", permission: Permissions.USER_MANAGE },
|
||
]
|
||
},
|
||
{
|
||
title: "Teaching",
|
||
icon: BookCopy,
|
||
href: "/admin/course-plans",
|
||
permission: Permissions.COURSE_PLAN_MANAGE,
|
||
items: [
|
||
{ title: "Course Plans", href: "/admin/course-plans", permission: Permissions.COURSE_PLAN_MANAGE },
|
||
{ title: "Electives", href: "/admin/elective", permission: Permissions.ELECTIVE_MANAGE },
|
||
]
|
||
},
|
||
{
|
||
title: "Scheduling",
|
||
icon: CalendarClock,
|
||
href: "/admin/scheduling/rules",
|
||
permission: Permissions.SCHEDULE_ADJUST,
|
||
items: [
|
||
{ title: "Rules", href: "/admin/scheduling/rules", permission: Permissions.SCHEDULE_ADJUST },
|
||
{ title: "Auto Schedule", href: "/admin/scheduling/auto", permission: Permissions.SCHEDULE_AUTO },
|
||
{ title: "Change Requests", href: "/admin/scheduling/changes", permission: Permissions.SCHEDULE_ADJUST },
|
||
]
|
||
},
|
||
{
|
||
title: "Attendance",
|
||
icon: CalendarCheck,
|
||
href: "/admin/attendance",
|
||
permission: Permissions.ATTENDANCE_READ,
|
||
},
|
||
{
|
||
title: "Announcements",
|
||
icon: Megaphone,
|
||
href: "/admin/announcements",
|
||
permission: Permissions.ANNOUNCEMENT_MANAGE,
|
||
},
|
||
{
|
||
title: "文件管理",
|
||
icon: Files,
|
||
href: "/admin/files",
|
||
permission: Permissions.FILE_READ,
|
||
},
|
||
{
|
||
title: "错题分析",
|
||
icon: BookX,
|
||
href: "/admin/error-book",
|
||
permission: Permissions.ERROR_BOOK_ANALYTICS_READ,
|
||
},
|
||
{
|
||
title: "课案管理",
|
||
icon: PenTool,
|
||
href: "/admin/lesson-plans",
|
||
permission: Permissions.LESSON_PLAN_READ,
|
||
},
|
||
{
|
||
title: "Audit Logs",
|
||
icon: ScrollText,
|
||
href: "/admin/audit-logs",
|
||
permission: Permissions.AUDIT_LOG_READ,
|
||
items: [
|
||
{ title: "Operation Logs", href: "/admin/audit-logs" },
|
||
{ title: "Login Logs", href: "/admin/audit-logs/login-logs" },
|
||
{ title: "Data Changes", href: "/admin/audit-logs/data-changes" },
|
||
]
|
||
},
|
||
...COMMON_NAV_ITEMS,
|
||
{
|
||
title: "AI 配置",
|
||
icon: Sparkles,
|
||
href: "/admin/ai-settings",
|
||
permission: Permissions.AI_CONFIGURE,
|
||
},
|
||
{
|
||
title: "Settings",
|
||
icon: Settings,
|
||
href: "/admin/settings",
|
||
permission: Permissions.SETTINGS_ADMIN,
|
||
},
|
||
],
|
||
teacher: [
|
||
{
|
||
title: "仪表盘",
|
||
icon: LayoutDashboard,
|
||
href: "/teacher/dashboard",
|
||
},
|
||
{
|
||
title: "教材",
|
||
icon: Library,
|
||
href: "/teacher/textbooks",
|
||
permission: Permissions.TEXTBOOK_READ,
|
||
},
|
||
{
|
||
title: "考试",
|
||
icon: FileQuestion,
|
||
href: "/teacher/exams",
|
||
permission: Permissions.EXAM_CREATE,
|
||
items: [
|
||
{ title: "全部考试", href: "/teacher/exams/all" },
|
||
{ title: "创建考试", href: "/teacher/exams/create", permission: Permissions.EXAM_CREATE },
|
||
]
|
||
},
|
||
{
|
||
title: "作业",
|
||
icon: PenTool,
|
||
href: "/teacher/homework",
|
||
permission: Permissions.HOMEWORK_CREATE,
|
||
items: [
|
||
{ title: "作业列表", href: "/teacher/homework/assignments" },
|
||
{ title: "提交记录", href: "/teacher/homework/submissions" },
|
||
]
|
||
},
|
||
{
|
||
title: "成绩",
|
||
icon: GraduationCap,
|
||
href: "/teacher/grades",
|
||
permission: Permissions.GRADE_RECORD_MANAGE,
|
||
items: [
|
||
{ title: "全部成绩", href: "/teacher/grades" },
|
||
{ title: "批量录入", href: "/teacher/grades/entry", permission: Permissions.GRADE_RECORD_MANAGE },
|
||
{ title: "成绩统计", href: "/teacher/grades/stats", permission: Permissions.GRADE_RECORD_READ },
|
||
{ title: "成绩分析", href: "/teacher/grades/analytics", permission: Permissions.GRADE_RECORD_READ },
|
||
]
|
||
},
|
||
{
|
||
title: "题库",
|
||
icon: ClipboardList,
|
||
href: "/teacher/questions",
|
||
permission: Permissions.QUESTION_READ,
|
||
},
|
||
{
|
||
title: "班级管理",
|
||
icon: Users,
|
||
href: "/teacher/classes",
|
||
permission: Permissions.CLASS_READ,
|
||
items: [
|
||
{ title: "我的班级", href: "/teacher/classes/my" },
|
||
{ title: "学生", href: "/teacher/classes/students" },
|
||
{ title: "课表", href: "/teacher/classes/schedule", permission: Permissions.CLASS_SCHEDULE },
|
||
]
|
||
},
|
||
{
|
||
title: "课程计划",
|
||
icon: CalendarRange,
|
||
href: "/teacher/course-plans",
|
||
permission: Permissions.COURSE_PLAN_READ,
|
||
},
|
||
{
|
||
title: "我的备课",
|
||
icon: PenTool,
|
||
href: "/teacher/lesson-plans",
|
||
permission: Permissions.LESSON_PLAN_READ,
|
||
},
|
||
{
|
||
title: "考勤",
|
||
icon: CalendarCheck,
|
||
href: "/teacher/attendance",
|
||
permission: Permissions.ATTENDANCE_MANAGE,
|
||
items: [
|
||
{ title: "考勤记录", href: "/teacher/attendance" },
|
||
{ title: "录入考勤", href: "/teacher/attendance/sheet", permission: Permissions.ATTENDANCE_MANAGE },
|
||
{ title: "考勤统计", href: "/teacher/attendance/stats", permission: Permissions.ATTENDANCE_READ },
|
||
]
|
||
},
|
||
{
|
||
title: "调课申请",
|
||
icon: CalendarClock,
|
||
href: "/teacher/schedule-changes",
|
||
permission: Permissions.SCHEDULE_ADJUST,
|
||
},
|
||
{
|
||
title: "学情诊断",
|
||
icon: Stethoscope,
|
||
href: "/teacher/diagnostic",
|
||
permission: Permissions.DIAGNOSTIC_READ,
|
||
},
|
||
{
|
||
title: "错题分析",
|
||
icon: BookX,
|
||
href: "/teacher/error-book",
|
||
permission: Permissions.ERROR_BOOK_ANALYTICS_READ,
|
||
},
|
||
{
|
||
title: "选修课",
|
||
icon: BookMarked,
|
||
href: "/teacher/elective",
|
||
permission: Permissions.ELECTIVE_MANAGE,
|
||
},
|
||
{
|
||
title: "年级管理",
|
||
icon: Briefcase,
|
||
href: "/management",
|
||
permission: Permissions.GRADE_MANAGE,
|
||
items: [
|
||
{ title: "年级班级", href: "/management/grade/classes" },
|
||
{ title: "年级仪表盘", href: "/management/grade/dashboard" },
|
||
{ title: "年级洞察", href: "/management/grade/insights" },
|
||
]
|
||
},
|
||
...COMMON_NAV_ITEMS,
|
||
],
|
||
grade_head: [
|
||
{
|
||
title: "仪表盘",
|
||
icon: LayoutDashboard,
|
||
href: "/management",
|
||
permission: Permissions.GRADE_MANAGE,
|
||
},
|
||
{
|
||
title: "年级管理",
|
||
icon: Briefcase,
|
||
href: "/management",
|
||
permission: Permissions.GRADE_MANAGE,
|
||
items: [
|
||
{ title: "年级班级", href: "/management/grade/classes" },
|
||
{ title: "年级仪表盘", href: "/management/grade/dashboard" },
|
||
{ title: "年级洞察", href: "/management/grade/insights" },
|
||
]
|
||
},
|
||
{
|
||
title: "考勤",
|
||
icon: CalendarCheck,
|
||
href: "/teacher/attendance",
|
||
permission: Permissions.ATTENDANCE_READ,
|
||
items: [
|
||
{ title: "考勤记录", href: "/teacher/attendance" },
|
||
{ title: "考勤统计", href: "/teacher/attendance/stats", permission: Permissions.ATTENDANCE_READ },
|
||
]
|
||
},
|
||
{
|
||
title: "成绩",
|
||
icon: GraduationCap,
|
||
href: "/teacher/grades",
|
||
permission: Permissions.GRADE_RECORD_READ,
|
||
items: [
|
||
{ title: "成绩统计", href: "/teacher/grades/stats", permission: Permissions.GRADE_RECORD_READ },
|
||
{ title: "成绩分析", href: "/teacher/grades/analytics", permission: Permissions.GRADE_RECORD_READ },
|
||
]
|
||
},
|
||
{
|
||
title: "错题分析",
|
||
icon: BookX,
|
||
href: "/teacher/error-book",
|
||
permission: Permissions.ERROR_BOOK_ANALYTICS_READ,
|
||
},
|
||
...COMMON_NAV_ITEMS,
|
||
],
|
||
teaching_head: [
|
||
{
|
||
title: "仪表盘",
|
||
icon: LayoutDashboard,
|
||
href: "/management",
|
||
permission: Permissions.GRADE_MANAGE,
|
||
},
|
||
{
|
||
title: "年级管理",
|
||
icon: Briefcase,
|
||
href: "/management",
|
||
permission: Permissions.GRADE_MANAGE,
|
||
items: [
|
||
{ title: "年级班级", href: "/management/grade/classes" },
|
||
{ title: "年级仪表盘", href: "/management/grade/dashboard" },
|
||
{ title: "年级洞察", href: "/management/grade/insights" },
|
||
]
|
||
},
|
||
{
|
||
title: "考勤",
|
||
icon: CalendarCheck,
|
||
href: "/teacher/attendance",
|
||
permission: Permissions.ATTENDANCE_READ,
|
||
items: [
|
||
{ title: "考勤记录", href: "/teacher/attendance" },
|
||
{ title: "考勤统计", href: "/teacher/attendance/stats", permission: Permissions.ATTENDANCE_READ },
|
||
]
|
||
},
|
||
{
|
||
title: "成绩",
|
||
icon: GraduationCap,
|
||
href: "/teacher/grades",
|
||
permission: Permissions.GRADE_RECORD_READ,
|
||
items: [
|
||
{ title: "成绩统计", href: "/teacher/grades/stats", permission: Permissions.GRADE_RECORD_READ },
|
||
{ title: "成绩分析", href: "/teacher/grades/analytics", permission: Permissions.GRADE_RECORD_READ },
|
||
]
|
||
},
|
||
{
|
||
title: "错题分析",
|
||
icon: BookX,
|
||
href: "/teacher/error-book",
|
||
permission: Permissions.ERROR_BOOK_ANALYTICS_READ,
|
||
},
|
||
...COMMON_NAV_ITEMS,
|
||
],
|
||
student: [
|
||
{
|
||
title: "Dashboard",
|
||
icon: LayoutDashboard,
|
||
href: "/student/dashboard",
|
||
},
|
||
{
|
||
title: "My Learning",
|
||
icon: BookOpen,
|
||
href: "/student/learning",
|
||
permission: Permissions.HOMEWORK_SUBMIT,
|
||
items: [
|
||
{ title: "Courses", href: "/student/learning/courses" },
|
||
{ title: "Assignments", href: "/student/learning/assignments", permission: Permissions.HOMEWORK_SUBMIT },
|
||
{ title: "Textbooks", href: "/student/learning/textbooks", permission: Permissions.TEXTBOOK_READ },
|
||
]
|
||
},
|
||
{
|
||
title: "Schedule",
|
||
icon: Calendar,
|
||
href: "/student/schedule",
|
||
permission: Permissions.CLASS_SCHEDULE,
|
||
},
|
||
{
|
||
title: "My Grades",
|
||
icon: GraduationCap,
|
||
href: "/student/grades",
|
||
permission: Permissions.GRADE_RECORD_READ,
|
||
},
|
||
{
|
||
title: "我的课案",
|
||
icon: PenTool,
|
||
href: "/student/lesson-plans",
|
||
permission: Permissions.LESSON_PLAN_READ,
|
||
},
|
||
{
|
||
title: "Attendance",
|
||
icon: CalendarCheck,
|
||
href: "/student/attendance",
|
||
permission: Permissions.ATTENDANCE_READ,
|
||
},
|
||
{
|
||
title: "Diagnostic",
|
||
icon: Stethoscope,
|
||
href: "/student/diagnostic",
|
||
permission: Permissions.DIAGNOSTIC_READ,
|
||
},
|
||
{
|
||
title: "错题本",
|
||
icon: BookX,
|
||
href: "/student/error-book",
|
||
permission: Permissions.ERROR_BOOK_READ,
|
||
},
|
||
{
|
||
title: "Electives",
|
||
icon: BookMarked,
|
||
href: "/student/elective",
|
||
permission: Permissions.ELECTIVE_SELECT,
|
||
},
|
||
...COMMON_NAV_ITEMS,
|
||
],
|
||
parent: [
|
||
{
|
||
title: "Dashboard",
|
||
icon: LayoutDashboard,
|
||
href: "/parent/dashboard",
|
||
},
|
||
{
|
||
title: "Grades",
|
||
icon: GraduationCap,
|
||
href: "/parent/grades",
|
||
permission: Permissions.GRADE_RECORD_READ,
|
||
},
|
||
{
|
||
title: "孩子课案",
|
||
icon: PenTool,
|
||
href: "/parent/lesson-plans",
|
||
permission: Permissions.LESSON_PLAN_READ,
|
||
},
|
||
{
|
||
title: "Attendance",
|
||
icon: CalendarCheck,
|
||
href: "/parent/attendance",
|
||
permission: Permissions.ATTENDANCE_READ,
|
||
},
|
||
{
|
||
title: "错题本",
|
||
icon: BookX,
|
||
href: "/parent/error-book",
|
||
permission: Permissions.ERROR_BOOK_READ,
|
||
},
|
||
{
|
||
title: "Leave Request",
|
||
icon: CalendarRange,
|
||
href: "/parent/leave",
|
||
},
|
||
...COMMON_NAV_ITEMS,
|
||
]
|
||
}
|