From e997abaf5e41f1c16042c7c3179e500e379eabc2 Mon Sep 17 00:00:00 2001 From: SpecialX <47072643+wangxiner55@users.noreply.github.com> Date: Mon, 22 Jun 2026 17:01:00 +0800 Subject: [PATCH] =?UTF-8?q?refactor(dashboard):=20V2=20=E5=AE=A1=E8=AE=A1?= =?UTF-8?q?=E9=87=8D=E6=9E=84=20=E2=80=94=20i18n=20=E8=A1=A5=E9=BD=90=20+?= =?UTF-8?q?=20=E5=85=B1=E4=BA=AB=E6=8A=BD=E8=B1=A1=20+=20=E5=8D=95?= =?UTF-8?q?=E6=B5=8B=20+=20a11y?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../004_architecture_impact_map.md | 143 ++++-- docs/architecture/005_architecture_data.json | 328 +++++++++----- .../audit/dashboard-audit-report-v2.md | 121 ++++++ .../admin-dashboard/admin-dashboard.tsx | 3 +- .../components/dashboard-greeting-header.tsx | 36 ++ .../student-dashboard-header.tsx | 17 +- .../student-dashboard-view.tsx | 18 +- .../student-dashboard/student-grades-card.tsx | 28 +- .../student-today-schedule-card.tsx | 18 +- .../student-upcoming-assignments-card.tsx | 42 +- .../teacher-dashboard/recent-submissions.tsx | 80 ++-- .../teacher-classes-card.tsx | 19 +- .../teacher-dashboard-header.tsx | 21 +- .../teacher-dashboard-view.tsx | 13 +- .../teacher-grade-trends.tsx | 14 +- .../teacher-homework-card.tsx | 31 +- .../teacher-quick-actions.tsx | 19 +- .../teacher-dashboard/teacher-schedule.tsx | 225 +++++----- .../components/block-renderer.tsx | 6 +- .../components/blocks/exercise-block.tsx | 8 +- .../components/blocks/text-study-block.tsx | 9 +- .../components/inline-question-editor.tsx | 23 +- .../components/knowledge-point-picker.tsx | 11 +- .../components/lesson-plan-card.tsx | 86 +++- .../components/lesson-plan-editor.tsx | 2 +- .../components/lesson-plan-list.tsx | 8 + .../components/publish-homework-dialog.tsx | 11 +- .../components/question-bank-picker.tsx | 11 +- .../components/template-picker.tsx | 2 +- .../components/version-history-drawer.tsx | 45 +- src/modules/lesson-preparation/constants.ts | 44 +- src/modules/lesson-preparation/data-access.ts | 46 +- .../hooks/use-lesson-plan-editor.ts | 7 +- .../providers/lesson-plan-provider.tsx | 189 ++++++++ .../lesson-preparation/publish-service.ts | 9 +- .../services/default-data-service.ts | 50 +++ src/shared/i18n/messages/en/dashboard.json | 74 +++- .../i18n/messages/en/lesson-preparation.json | 14 +- src/shared/i18n/messages/zh-CN/dashboard.json | 74 +++- .../messages/zh-CN/lesson-preparation.json | 14 +- .../dashboard/dashboard-utils.test.ts | 408 ++++++++++++++++++ 41 files changed, 1811 insertions(+), 516 deletions(-) create mode 100644 docs/architecture/audit/dashboard-audit-report-v2.md create mode 100644 src/modules/dashboard/components/dashboard-greeting-header.tsx create mode 100644 src/modules/lesson-preparation/providers/lesson-plan-provider.tsx create mode 100644 src/modules/lesson-preparation/services/default-data-service.ts create mode 100644 tests/integration/dashboard/dashboard-utils.test.ts diff --git a/docs/architecture/004_architecture_impact_map.md b/docs/architecture/004_architecture_impact_map.md index 0b82def..62d65da 100644 --- a/docs/architecture/004_architecture_impact_map.md +++ b/docs/architecture/004_architecture_impact_map.md @@ -948,7 +948,7 @@ src/auth.ts ──▶ import { ... } from "@/shared/lib/permissions" - Actions:`getAdminDashboardAction` / `getTeacherDashboardAction` / `getStudentDashboardAction` / `getParentDashboardAction`(均调用 `requirePermission()` 校验对应 `DASHBOARD_*_READ` 权限) - Data-access:`getAdminDashboardData`(并行调用 6 个模块 stats 函数) - Lib 纯函数:`toWeekday` / `countStudentAssignments` / `sortUpcomingAssignments` / `filterTodaySchedule` / `computeTeacherMetrics` / `getGreetingKey` -- Components:`AdminDashboardView` / `TeacherDashboardView` / `StudentDashboard` / `UserGrowthChart`(均接入 next-intl i18n) +- Components:`AdminDashboardView` / `TeacherDashboardView` / `StudentDashboard` / `UserGrowthChart` / `DashboardGreetingHeader`(共享问候头部,V2 抽象)/ `DashboardSection`(分区 Error Boundary + Suspense + 骨架屏)(均接入 next-intl i18n) **依赖关系**: - 依赖:`shared/*`、`@/auth`、`classes`(通过 data-access)、`homework`(通过 data-access)、`users`(通过 data-access)、`parent`(通过 data-access.getParentDashboardData)、`textbooks`/`questions`/`exams`(通过各模块 dashboard stats 函数)、`recharts`、`next-intl` @@ -969,6 +969,10 @@ src/auth.ts ──▶ import { ... } from "@/shared/lib/permissions" - ✅ P2 已修复(2026-06-22):新增 `components/dashboard-section.tsx`,每个独立数据区块用 Error Boundary + Suspense + 骨架屏包裹,单区块崩溃/加载不波及整页(5 种骨架变体:stats/card/chart/table/list) - ℹ️ V1 新增:`AdminDashboardData` 类型含 `userGrowth`/`homeworkTrend` 字段,`data-access.ts` 当前返回空数组占位,待后续接入真实统计 - ℹ️ parent 仪表盘组件仍位于 `modules/parent/components/parent-dashboard.tsx`,通过 `dashboard/actions.getParentDashboardAction` 调用(架构决策:保留在 parent 模块以避免移动文件破坏其他 import) +- ✅ P0 已修复(2026-06-22 V2):10 个子组件 i18n 遗漏全部补齐(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 已修复(2026-06-22 V2):抽象共享组件 `DashboardGreetingHeader`,消除 teacher/student 头部 90% 重复代码 +- ✅ P2 已修复(2026-06-22 V2):为 6 个纯函数添加 31 个单元测试(`tests/integration/dashboard/dashboard-utils.test.ts`) +- ✅ P2 已修复(2026-06-22 V2):a11y 增强 — admin 表格 ``、teacher/student 视图语义化标签(`
` / `
` / `