| 123456789101112131415161718192021222324252627282930 |
- diff --git a/server/src/modules/book-generator/langgraph-generator.ts b/server/src/modules/book-generator/langgraph-generator.ts
- index 3f502c6..5128bdc 100644
- --- a/server/src/modules/book-generator/langgraph-generator.ts
- +++ b/server/src/modules/book-generator/langgraph-generator.ts
- @@ -335,7 +335,25 @@ async function writeChaptersNode(state: typeof GraphState.State): Promise<Partia
- let currentWordCount = await getGeneratedWordCount(state.bookId);
- console.log(`[LangGraph] 当前已生成字数: ${currentWordCount}`);
-
- + // 查询已完成的章节,支持断点续传
- + const completedChapterNumbers = new Set<number>();
- + for (const ch of book.outline.chapters) {
- + const chapter = await bookStore.getChapter(state.bookId, ch.number);
- + if (chapter && chapter.status === 'completed') {
- + completedChapterNumbers.add(ch.number);
- + }
- + }
- +
- + if (completedChapterNumbers.size > 0) {
- + console.log(`[LangGraph] ✅ 跳过 ${completedChapterNumbers.size} 个已完成的章节: [${Array.from(completedChapterNumbers).join(', ')}]`);
- + }
- +
- for (const chapterOutline of book.outline.chapters) {
- + // 跳过已完成的章节
- + if (completedChapterNumbers.has(chapterOutline.number)) {
- + console.log(`[LangGraph] 跳过第${chapterOutline.number}章(已完成)`);
- + continue;
- + }
- // ===== 额度监控:在生成章节前检查额度 =====
- console.log(`[LangGraph] 检查第${chapterOutline.number}章额度,当前累计: ${currentWordCount}字`);
- try {
|