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:
@@ -1,21 +1,26 @@
|
||||
import type { BlockType, TemplateBlockSkeleton, TemplateScope } from "./types";
|
||||
|
||||
// block 类型 → 中文默认标题
|
||||
export const BLOCK_TYPE_LABELS: Record<BlockType, string> = {
|
||||
objective: "教学目标",
|
||||
key_point: "教学重难点",
|
||||
import: "导入",
|
||||
new_teaching: "新授",
|
||||
consolidation: "巩固练习",
|
||||
summary: "课堂小结",
|
||||
homework: "作业布置",
|
||||
blackboard: "板书设计",
|
||||
text_study: "文本研习",
|
||||
exercise: "练习/作业",
|
||||
rich_text: "自定义环节",
|
||||
reflection: "教学反思",
|
||||
// block 类型 → i18n 键(实际文本由 useTranslations("lessonPreparation").blockType.${type} 翻译)
|
||||
// 保留此映射用于:1) 新节点默认标题的 i18n 键查找 2) 类型守卫
|
||||
export const BLOCK_TYPE_KEYS: Record<BlockType, string> = {
|
||||
objective: "objective",
|
||||
key_point: "key_point",
|
||||
import: "import",
|
||||
new_teaching: "new_teaching",
|
||||
consolidation: "consolidation",
|
||||
summary: "summary",
|
||||
homework: "homework",
|
||||
blackboard: "blackboard",
|
||||
text_study: "text_study",
|
||||
exercise: "exercise",
|
||||
rich_text: "rich_text",
|
||||
reflection: "reflection",
|
||||
};
|
||||
|
||||
// 向后兼容:保留 BLOCK_TYPE_LABELS 名称但值为 i18n 键(实际翻译由组件层完成)
|
||||
// @deprecated 使用 BLOCK_TYPE_KEYS 或 useTranslations("lessonPreparation").blockType.${type} 替代
|
||||
export const BLOCK_TYPE_LABELS: Record<BlockType, string> = BLOCK_TYPE_KEYS;
|
||||
|
||||
// 富文本类 block(共享同一编辑组件)
|
||||
export const RICH_TEXT_BLOCK_TYPES: BlockType[] = [
|
||||
"objective",
|
||||
@@ -100,8 +105,11 @@ export const SYSTEM_TEMPLATES: SystemTemplateDef[] = [
|
||||
},
|
||||
];
|
||||
|
||||
export const LESSON_PLAN_STATUS_LABELS: Record<string, string> = {
|
||||
draft: "草稿",
|
||||
published: "已发布",
|
||||
archived: "已归档",
|
||||
export const LESSON_PLAN_STATUS_KEYS: Record<string, string> = {
|
||||
draft: "draft",
|
||||
published: "published",
|
||||
archived: "archived",
|
||||
};
|
||||
|
||||
// @deprecated 使用 useTranslations("lessonPreparation").status.${key} 替代
|
||||
export const LESSON_PLAN_STATUS_LABELS: Record<string, string> = LESSON_PLAN_STATUS_KEYS;
|
||||
|
||||
Reference in New Issue
Block a user