refactor(dashboard): V2 审计重构 — i18n 补齐 + 共享抽象 + 单测 + a11y

V2 审计报告(docs/architecture/audit/dashboard-audit-report-v2.md)发现并修复:

- P0 i18n:10 个子组件硬编码字符串全部接入 next-intl(teacher-quick-actions /
  teacher-classes-card / teacher-homework-card / teacher-schedule /
  recent-submissions / teacher-grade-trends / student-grades-card /
  student-today-schedule-card / student-upcoming-assignments-card /
  admin-dashboard),新增 ~50 个翻译键
- P1 共享抽象:新增 DashboardGreetingHeader 组件,消除 teacher/student
  头部 90% 重复代码,两个 Header 改为薄包装
- P2 单测:为 6 个纯函数添加 31 个单元测试
  (tests/integration/dashboard/dashboard-utils.test.ts)
- P2 a11y:admin 表格 caption、teacher/student 视图语义化标签
  (header / section aria-label / aside aria-label)
- 同步架构图 004/005
This commit is contained in:
SpecialX
2026-06-22 17:01:00 +08:00
parent 10c668f36a
commit e997abaf5e
41 changed files with 1811 additions and 516 deletions

View File

@@ -1,12 +1,14 @@
"use client"
import { TrendingUp } from "lucide-react"
import { useTranslations } from "next-intl"
import { ChartCardShell } from "@/shared/components/charts/chart-card-shell"
import { TrendLineChart } from "@/shared/components/charts/trend-line-chart"
import type { TeacherGradeTrendItem } from "@/modules/homework/types"
export function TeacherGradeTrends({ trends }: { trends: TeacherGradeTrendItem[] }) {
const t = useTranslations("dashboard")
const hasTrends = trends.length > 0
const chartData = trends.map((item) => {
@@ -22,14 +24,14 @@ export function TeacherGradeTrends({ trends }: { trends: TeacherGradeTrendItem[]
return (
<ChartCardShell
title="Class Performance"
description={`Average scores for the last ${trends.length} assignments`}
title={t("sections.classPerformance")}
description={t("chart.classPerformanceDesc", { count: trends.length })}
icon={TrendingUp}
iconClassName="text-primary"
titleClassName="text-base font-medium"
isEmpty={!hasTrends}
emptyTitle="No data available"
emptyDescription="Publish assignments to see class performance trends."
emptyTitle={t("empty.noData")}
emptyDescription={t("empty.noDataDesc")}
emptyClassName="h-[200px] p-0"
className="col-span-1"
>
@@ -39,7 +41,7 @@ export function TeacherGradeTrends({ trends }: { trends: TeacherGradeTrendItem[]
series={[
{
dataKey: "score",
name: "Average Score (%)",
name: t("chart.averageScorePercent"),
color: "hsl(var(--primary))",
dotRadius: 4,
activeDotRadius: 6,
@@ -65,7 +67,7 @@ export function TeacherGradeTrends({ trends }: { trends: TeacherGradeTrendItem[]
<span className="text-xl font-bold tabular-nums">{item.score}%</span>
</div>
<div className="text-[10px] text-muted-foreground">
{item.submissionCount}/{item.totalStudents} submitted
{t("chart.submittedCount", { submitted: item.submissionCount, total: item.totalStudents })}
</div>
</div>
))}