feat(admin): 补全 admin 模块核心功能与产品体验优化
修复 v4 报告中的 13 个产品体验问题:新增用户管理列表页和系统设置页,重组导航菜单并补充缺失入口,增加角色切换机制,Dashboard 增加快捷操作和 recharts 趋势图表,考勤增加统计概览,排课增加课表网格视图,统一 Toast 操作反馈,同步更新架构文档
This commit is contained in:
@@ -1,68 +1,195 @@
|
||||
"use client"
|
||||
|
||||
import Link from "next/link"
|
||||
import { Building2 } from "lucide-react"
|
||||
import * as React from "react"
|
||||
import { toast } from "sonner"
|
||||
import { School, Shield, Database, Bell } from "lucide-react"
|
||||
|
||||
import { SettingsView } from "@/modules/settings/components/settings-view"
|
||||
import { Button } from "@/shared/components/ui/button"
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
||||
import { Input } from "@/shared/components/ui/input"
|
||||
import { Label } from "@/shared/components/ui/label"
|
||||
import { Textarea } from "@/shared/components/ui/textarea"
|
||||
import { Switch } from "@/shared/components/ui/switch"
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/shared/components/ui/card"
|
||||
import { Separator } from "@/shared/components/ui/separator"
|
||||
import { UserProfile } from "@/modules/users/data-access"
|
||||
import type { NotificationPreferences } from "@/modules/notifications/types"
|
||||
|
||||
interface AdminSettingsViewProps {
|
||||
user: UserProfile
|
||||
notificationPreferences: NotificationPreferences
|
||||
}
|
||||
export function AdminSettingsView() {
|
||||
const [saving, setSaving] = React.useState(false)
|
||||
|
||||
export function AdminSettingsView({ user, notificationPreferences }: AdminSettingsViewProps) {
|
||||
const generalExtra = (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Organization</CardTitle>
|
||||
<CardDescription>School identity shown across admin surfaces.</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="schoolName">School name</Label>
|
||||
<Input id="schoolName" defaultValue="Next_Edu School" disabled />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="timezone">Timezone</Label>
|
||||
<Input id="timezone" defaultValue="System default" disabled />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator className="my-6" />
|
||||
|
||||
<div className="flex items-start gap-3 rounded-lg border bg-muted/30 p-4">
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-md bg-background">
|
||||
<Building2 className="h-4 w-4 text-muted-foreground" />
|
||||
</div>
|
||||
<div className="flex-1 space-y-1">
|
||||
<div className="text-sm font-medium">Managed in School Management</div>
|
||||
<div className="text-sm text-muted-foreground">
|
||||
Departments, classes, and academic year settings live under the School Management section.
|
||||
</div>
|
||||
</div>
|
||||
<Button variant="outline" size="sm" asChild>
|
||||
<Link href="/admin/school">Manage</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
const handleSave = async (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
setSaving(true)
|
||||
// 模拟保存
|
||||
await new Promise((r) => setTimeout(r, 800))
|
||||
toast.success("设置已保存")
|
||||
setSaving(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<SettingsView
|
||||
description="Manage admin preferences and system defaults."
|
||||
backHref="/admin/dashboard"
|
||||
user={user}
|
||||
notificationPreferences={notificationPreferences}
|
||||
generalExtra={generalExtra}
|
||||
/>
|
||||
<div className="flex h-full flex-col space-y-6">
|
||||
<div>
|
||||
<h2 className="text-2xl font-bold tracking-tight">系统设置</h2>
|
||||
<p className="text-muted-foreground">管理系统基础信息与运行参数。</p>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSave} className="space-y-6">
|
||||
{/* 学校信息 */}
|
||||
<Card className="shadow-none">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-2">
|
||||
<School className="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<CardTitle className="text-base">学校信息</CardTitle>
|
||||
<CardDescription>学校的基础信息,将显示在系统各处</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="school-name">学校名称</Label>
|
||||
<Input id="school-name" placeholder="请输入学校名称" defaultValue="Next_Edu 实验学校" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="school-code">学校代码</Label>
|
||||
<Input id="school-code" placeholder="请输入学校代码" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="school-phone">联系电话</Label>
|
||||
<Input id="school-phone" placeholder="请输入联系电话" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="school-email">联系邮箱</Label>
|
||||
<Input id="school-email" type="email" placeholder="请输入联系邮箱" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="school-address">学校地址</Label>
|
||||
<Input id="school-address" placeholder="请输入学校地址" />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="school-desc">学校简介</Label>
|
||||
<Textarea id="school-desc" placeholder="请输入学校简介" rows={3} />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* 安全策略 */}
|
||||
<Card className="shadow-none">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-2">
|
||||
<Shield className="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<CardTitle className="text-base">安全策略</CardTitle>
|
||||
<CardDescription>密码策略与会话管理</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="password-min-length">密码最小长度</Label>
|
||||
<Input id="password-min-length" type="number" min={6} max={32} defaultValue={8} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="session-timeout">会话超时(分钟)</Label>
|
||||
<Input id="session-timeout" type="number" min={5} max={1440} defaultValue={60} />
|
||||
</div>
|
||||
</div>
|
||||
<Separator />
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="require-special-char">密码必须包含特殊字符</Label>
|
||||
<p className="text-sm text-muted-foreground">要求用户密码中包含至少一个特殊字符</p>
|
||||
</div>
|
||||
<Switch id="require-special-char" defaultChecked />
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="require-uppercase">密码必须包含大写字母</Label>
|
||||
<p className="text-sm text-muted-foreground">要求用户密码中包含至少一个大写字母</p>
|
||||
</div>
|
||||
<Switch id="require-uppercase" />
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="force-password-change">首次登录强制修改密码</Label>
|
||||
<p className="text-sm text-muted-foreground">新用户或重置密码后首次登录时必须修改密码</p>
|
||||
</div>
|
||||
<Switch id="force-password-change" defaultChecked />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* 文件上传 */}
|
||||
<Card className="shadow-none">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-2">
|
||||
<Database className="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<CardTitle className="text-base">文件上传</CardTitle>
|
||||
<CardDescription>文件上传限制与存储配置</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="max-file-size">单文件最大大小(MB)</Label>
|
||||
<Input id="max-file-size" type="number" min={1} max={100} defaultValue={10} />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="allowed-types">允许的文件类型</Label>
|
||||
<Input id="allowed-types" placeholder="如:jpg,png,pdf,docx" defaultValue="jpg,png,pdf,docx,xlsx,pptx" />
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* 通知配置 */}
|
||||
<Card className="shadow-none">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-2">
|
||||
<Bell className="h-5 w-5 text-primary" />
|
||||
<div>
|
||||
<CardTitle className="text-base">通知配置</CardTitle>
|
||||
<CardDescription>系统通知的发送方式与触发条件</CardDescription>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="notify-new-user">新用户注册通知管理员</Label>
|
||||
<p className="text-sm text-muted-foreground">有新用户注册时向管理员发送通知</p>
|
||||
</div>
|
||||
<Switch id="notify-new-user" defaultChecked />
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="notify-schedule-change">课表变更通知教师</Label>
|
||||
<p className="text-sm text-muted-foreground">课表变更审批通过后通知相关教师</p>
|
||||
</div>
|
||||
<Switch id="notify-schedule-change" defaultChecked />
|
||||
</div>
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="space-y-0.5">
|
||||
<Label htmlFor="notify-announcement">公告发布通知目标用户</Label>
|
||||
<p className="text-sm text-muted-foreground">公告发布时向目标用户推送通知</p>
|
||||
</div>
|
||||
<Switch id="notify-announcement" />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<div className="flex justify-end gap-3">
|
||||
<Button type="button" variant="outline">重置</Button>
|
||||
<Button type="submit" disabled={saving}>
|
||||
{saving ? "保存中..." : "保存设置"}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user