Files
NextEdu/src/modules/lesson-preparation/constants.ts
SpecialX e997abaf5e 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
2026-06-22 17:01:00 +08:00

116 lines
3.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import type { BlockType, TemplateBlockSkeleton, TemplateScope } from "./types";
// 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",
"key_point",
"import",
"new_teaching",
"consolidation",
"summary",
"homework",
"blackboard",
"rich_text",
"reflection",
];
// 系统预设模板骨架seed 用)
export interface SystemTemplateDef {
id: string; // 固定 ID便于幂等
name: string;
scope: TemplateScope;
blocks: TemplateBlockSkeleton[];
}
export const SYSTEM_TEMPLATES: SystemTemplateDef[] = [
{
id: "tpl_regular",
name: "常规课",
scope: "regular",
blocks: [
{ type: "objective", title: "教学目标", hint: "明确本课的知识、能力、情感目标" },
{ type: "key_point", title: "教学重难点", hint: "标注重点与难点及突破策略" },
{ type: "import", title: "导入", hint: "情境导入/复习导入/问题导入" },
{ type: "new_teaching", title: "新授", hint: "核心教学活动设计" },
{ type: "consolidation", title: "巩固练习", hint: "课堂练习,检验学习效果" },
{ type: "summary", title: "课堂小结", hint: "归纳本课要点" },
{ type: "homework", title: "作业布置", hint: "课后作业说明(如需下发请用练习块)" },
{ type: "blackboard", title: "板书设计", hint: "板书结构示意" },
],
},
{
id: "tpl_review",
name: "复习课",
scope: "review",
blocks: [
{ type: "objective", title: "复习目标" },
{ type: "rich_text", title: "知识网络梳理", hint: "构建知识结构图" },
{ type: "rich_text", title: "典型例题精讲" },
{ type: "rich_text", title: "变式训练" },
{ type: "exercise", title: "当堂检测", hint: "purpose 选 class_practice" },
{ type: "summary", title: "课堂小结" },
],
},
{
id: "tpl_experiment",
name: "实验课",
scope: "experiment",
blocks: [
{ type: "objective", title: "实验目的" },
{ type: "rich_text", title: "器材准备" },
{ type: "rich_text", title: "实验步骤" },
{ type: "rich_text", title: "观察记录表" },
{ type: "rich_text", title: "交流讨论" },
{ type: "summary", title: "课堂小结" },
],
},
{
id: "tpl_inquiry",
name: "探究课",
scope: "inquiry",
blocks: [
{ type: "rich_text", title: "情境导入" },
{ type: "rich_text", title: "问题驱动" },
{ type: "rich_text", title: "小组探究" },
{ type: "rich_text", title: "成果展示" },
{ type: "rich_text", title: "归纳提升" },
],
},
{
id: "tpl_blank",
name: "空白模板",
scope: "blank",
blocks: [],
},
];
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;