feat: 完成 P1 全部功能 + 修复 proxy 导出 + 切换 MySQL 端口至 14013

## P1 功能(20 项)
- 站内消息系统、家长仪表盘、学生考勤管理
- Excel 导入导出、用户批量导入、成绩导出
- 排课规则+自动排课+课表调整
- 成绩趋势+对比分析、密码安全策略、速率限制
- 数据变更日志、文件预览+存储策略、全文检索
- 依赖审计集成 CI、数据库定时备份、E2E 测试完善
- 通知偏好管理

## 基础设施修复
- src/proxy.ts: 将 middleware 导出重命名为 proxy(Next.js 16 要求)
- .env: MySQL 端口从 13002 切换至 14013
- scripts/create-db.ts: 新增数据库初始化脚本

## 架构文档同步
- 004_architecture_impact_map.md 和 005_architecture_data.json
  完整记录所有新增表、模块、路由、权限、依赖关系
This commit is contained in:
SpecialX
2026-06-17 13:44:37 +08:00
parent 125f7ec54c
commit 3b6272c99d
195 changed files with 27274 additions and 416 deletions

View File

@@ -0,0 +1,163 @@
"use client"
import Link from "next/link"
import { BarChart3, Trophy } from "lucide-react"
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts"
import { Badge } from "@/shared/components/ui/badge"
import { Card, CardContent, CardHeader, CardTitle } from "@/shared/components/ui/card"
import { EmptyState } from "@/shared/components/ui/empty-state"
import { ChartContainer, ChartTooltip, ChartTooltipContent } from "@/shared/components/ui/chart"
import { formatDate } from "@/shared/lib/utils"
import type { StudentDashboardGradeProps } from "@/modules/homework/types"
const chartConfig = {
score: {
label: "Score (%)",
color: "hsl(var(--primary))",
},
}
export function ChildGradeSummary({
grades,
childId,
childName,
}: {
grades: StudentDashboardGradeProps
childId: string
childName: string
}) {
const hasGradeTrend = grades.trend.length > 0
const ranking = grades.ranking
const latestGrade = grades.trend[grades.trend.length - 1]
const chartData = grades.trend.map((item) => ({
title: item.assignmentTitle,
score: Math.round(item.percentage),
fullTitle: item.assignmentTitle,
submittedAt: formatDate(item.submittedAt),
rawScore: item.score,
maxScore: item.maxScore,
}))
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2 text-base">
<BarChart3 className="h-4 w-4 text-muted-foreground" />
{childName}&apos;s Grades
</CardTitle>
</CardHeader>
<CardContent>
{!hasGradeTrend ? (
<EmptyState
icon={BarChart3}
title="No graded work yet"
description="Finish and submit assignments to see score trend."
className="border-none h-60"
/>
) : (
<div className="space-y-4">
<div className="grid grid-cols-2 gap-3">
<div className="rounded-md border bg-card p-3">
<div className="text-xs text-muted-foreground flex items-center gap-1">
<BarChart3 className="h-3 w-3" />
Latest Score
</div>
<div className="text-xl font-semibold tabular-nums">
{latestGrade ? `${Math.round(latestGrade.percentage)}%` : "-"}
</div>
{latestGrade ? (
<div className="text-xs text-muted-foreground tabular-nums">
{latestGrade.score}/{latestGrade.maxScore}
</div>
) : null}
</div>
<div className="rounded-md border bg-card p-3">
<div className="text-xs text-muted-foreground flex items-center gap-1">
<Trophy className="h-3 w-3" />
Class Rank
</div>
<div className="text-xl font-semibold tabular-nums">
{ranking ? `${ranking.rank}/${ranking.classSize}` : "-"}
</div>
{ranking ? (
<div className="text-xs text-muted-foreground">Current position</div>
) : null}
</div>
</div>
<div className="rounded-md border bg-card p-3">
<ChartContainer config={chartConfig} className="h-[160px] w-full">
<LineChart data={chartData} margin={{ left: 8, right: 8, top: 8, bottom: 8 }}>
<CartesianGrid vertical={false} strokeDasharray="4 4" strokeOpacity={0.4} />
<XAxis
dataKey="title"
tickLine={false}
axisLine={false}
tickMargin={8}
tickFormatter={(value) =>
value.slice(0, 8) + (value.length > 8 ? "..." : "")
}
/>
<YAxis
domain={[0, 100]}
tickLine={false}
axisLine={false}
tickFormatter={(value) => `${value}%`}
width={30}
/>
<ChartTooltip
cursor={{
stroke: "hsl(var(--muted-foreground))",
strokeWidth: 1,
strokeDasharray: "4 4",
}}
content={
<ChartTooltipContent
indicator="line"
labelKey="fullTitle"
className="w-[200px]"
/>
}
/>
<Line
dataKey="score"
type="monotone"
stroke="var(--color-score)"
strokeWidth={2}
dot={{ fill: "var(--color-score)", r: 3, strokeWidth: 2 }}
activeDot={{ r: 5, strokeWidth: 0 }}
/>
</LineChart>
</ChartContainer>
</div>
{grades.recent.length > 0 ? (
<div className="space-y-2">
<div className="text-xs font-medium uppercase text-muted-foreground">
Recent Grades
</div>
{grades.recent.slice(0, 3).map((r) => (
<Link
key={r.assignmentId}
href={`/parent/children/${childId}`}
className="flex items-center justify-between rounded-md border bg-card p-2 hover:bg-muted/50 transition-colors"
>
<div className="min-w-0 flex-1">
<div className="font-medium text-sm truncate">{r.assignmentTitle}</div>
<div className="text-xs text-muted-foreground">{formatDate(r.submittedAt)}</div>
</div>
<Badge variant="secondary" className="tabular-nums shrink-0 ml-2">
{r.score}/{r.maxScore}
</Badge>
</Link>
))}
</div>
) : null}
</div>
)}
</CardContent>
</Card>
)
}