refactor(lesson-preparation): print-view 适配 V4
- export.ts 已使用 order 排序,无画布依赖 - 新增 interaction block 的 flatten 逻辑(设计意图 + 对话轮次) - 更新文档注释(12 种 Block)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* V5-4:课案导出/打印工具
|
||||
* V5-4:课案导出/打印工具(V4 适配:按 order 排序,无画布依赖)
|
||||
*
|
||||
* 将画布式 LessonPlanDocument 扁平化为线性教学环节列表,
|
||||
* 将 LessonPlanDocument 扁平化为线性教学环节列表,
|
||||
* 供打印视图(print-view.tsx)渲染。支持详细版/简洁版两种模式:
|
||||
* - detailed: 包含所有 11 种 Block
|
||||
* - detailed: 包含所有 12 种 Block(含 V4 interaction)
|
||||
* - concise: 仅包含 objective / new_teaching / exercise / homework
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,7 @@ import type {
|
||||
ExerciseBlockData,
|
||||
HomeworkBlockData,
|
||||
ImportBlockData,
|
||||
InteractionBlockData,
|
||||
KeyPointBlockData,
|
||||
LessonPlan,
|
||||
LessonPlanDocument,
|
||||
@@ -152,6 +153,8 @@ function flattenBlockData(type: string, data: BlockData): string[] {
|
||||
return flattenTextStudy(data as TextStudyBlockData);
|
||||
case "rich_text":
|
||||
return flattenRichText(data as RichTextBlockData);
|
||||
case "interaction":
|
||||
return flattenInteraction(data as InteractionBlockData);
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
@@ -261,6 +264,19 @@ function flattenRichText(data: RichTextBlockData): string[] {
|
||||
return text.length > 0 ? [text] : [];
|
||||
}
|
||||
|
||||
function flattenInteraction(data: InteractionBlockData): string[] {
|
||||
const lines: string[] = [];
|
||||
if (data.designIntent) lines.push(`设计意图:${data.designIntent}`);
|
||||
data.turns.forEach((turn, i) => {
|
||||
const roleLabel = turn.role === "teacher" ? "师" : "生";
|
||||
lines.push(`第 ${i + 1} 轮 [${roleLabel}]:${turn.content}`);
|
||||
if (turn.role === "teacher" && turn.expectedAnswer) {
|
||||
lines.push(` 预期回答:${turn.expectedAnswer}`);
|
||||
}
|
||||
});
|
||||
return lines;
|
||||
}
|
||||
|
||||
// 仅用于类型推导的本地导入别名,避免在 switch case 中重复 import
|
||||
type ObjectiveItem = ObjectiveBlockData["objectives"][number];
|
||||
type HomeworkAssignment = HomeworkBlockData["assignments"][number];
|
||||
|
||||
Reference in New Issue
Block a user