diff --git a/api/app/tasks/memoir_tasks.py b/api/app/tasks/memoir_tasks.py index c70e895..f2b2a73 100644 --- a/api/app/tasks/memoir_tasks.py +++ b/api/app/tasks/memoir_tasks.py @@ -387,10 +387,13 @@ def _save_narrative_to_sections(db: Session, chapter, narrative: str, title: str def _placeholder_for_segment(seg: dict, order_idx: int) -> dict | None: ph = seg.get("placeholder_info") if ph and ph.get("placeholder") and ph.get("description"): + # 确保有 index,build_initial_image_assets 依赖此字段 + if "index" not in ph: + ph = {**ph, "index": order_idx} return ph content = (seg.get("content") or "").strip() desc = (content[:50] + "…") if len(content) > 50 else (content or "章节配图") - return {"placeholder": f"{{{{{{{{IMAGE:{desc}}}}}}}}}", "description": desc} + return {"placeholder": f"{{{{{{{{IMAGE:{desc}}}}}}}}}", "description": desc, "index": order_idx} # 按顺序创建 section,每 3 个 section 对应 1 张配图 for i, seg in enumerate(segments):