"use client"; import { useMemo } from "react"; import { useTranslations } from "next-intl"; import { Book } from "lucide-react"; import type { LessonPlanDocument, LessonPlanNode, TeachingStage, } from "../types"; import { TEACHING_STAGE_KEYS } from "../types"; import { getNodeColor, getNodeSummary } from "../lib/node-summary"; import { cn } from "@/shared/lib/utils"; interface Props { doc: LessonPlanDocument; textbookTitle?: string; chapterTitle?: string; } /** * V5-13 P3:移动端只读视图。 * * 在小屏设备上以线性卡片列表替代 React Flow 画布, * 按教学阶段(V5-15)分组展示节点,提升可读性。 * 仅展示,无编辑交互。 */ export function LessonPlanMobileView({ doc, textbookTitle, chapterTitle }: Props) { const t = useTranslations("lessonPreparation"); // 教学节点按 stage 分组(未归类的归入"其他") const grouped = useMemo(() => { const teachingNodes = doc.nodes.filter( (n): n is LessonPlanNode => n.type !== "textbook_content", ); const groups: Record = {}; const unstaged: LessonPlanNode[] = []; for (const n of teachingNodes) { if (n.stage) { const key = n.stage as TeachingStage; if (!groups[key]) groups[key] = []; groups[key].push(n); } else { unstaged.push(n); } } return { groups, unstaged }; }, [doc.nodes]); return (
{/* 顶部信息条 */} {(textbookTitle || chapterTitle) && (
{textbookTitle && (
)} {chapterTitle && (
{chapterTitle}
)}
)}
{/* 按阶段分组渲染 */} {TEACHING_STAGE_KEYS.map((stage) => { const nodes = grouped.groups[stage]; if (!nodes || nodes.length === 0) return null; return (

{t(`editor.stage.${stage}`)}

{nodes.map((n) => ( ))}
); })} {/* 未归类节点 */} {grouped.unstaged.length > 0 && (
{TEACHING_STAGE_KEYS.some((s) => grouped.groups[s]?.length > 0) && (

{t("editor.stageNone")}

)} {grouped.unstaged.map((n) => ( ))}
)}
); } function MobileNodeCard({ node, t, }: { node: LessonPlanNode; t: ReturnType; }) { const color = getNodeColor(node.type); const summary = getNodeSummary(node, (key, values) => t(key, values)); const diff = node.differentiation; return (
); }