From 640c5e1712df8a47293402cb23ed062dc859acd0 Mon Sep 17 00:00:00 2001 From: xiamuceer Date: Fri, 10 Apr 2026 10:10:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=8B=86=E4=B9=A6?= =?UTF-8?q?=E7=AB=A0=E8=8A=82=E6=95=B0=E8=AE=BE=E7=BD=AE=E4=B8=8D=E7=94=9F?= =?UTF-8?q?=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/BookImport.tsx | 43 +++++++++++++++++++++++++------ 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/BookImport.tsx b/frontend/src/pages/BookImport.tsx index ac64f64..6d0e07b 100644 --- a/frontend/src/pages/BookImport.tsx +++ b/frontend/src/pages/BookImport.tsx @@ -48,6 +48,8 @@ type BookImportPageCache = { applyMessage: string; applyError: string | null; isApplyComplete: boolean; + extractMode: BookImportExtractMode; + tailChapterCount: number; cachedAt: number; }; @@ -173,6 +175,16 @@ export default function BookImport() { retrying, ]); + const normalizedTailChapterCount = useMemo( + () => Math.max(5, Math.ceil(tailChapterCount / 5) * 5), + [tailChapterCount] + ); + const effectiveExtractMode = useMemo( + () => (normalizedTailChapterCount > 50 ? 'full' : extractMode), + [extractMode, normalizedTailChapterCount] + ); + const rangeLocked = Boolean(taskId || taskStatus || preview || creatingTask || applying || retrying); + const stepItems = [ { title: '上传文件' }, { title: '解析中' }, @@ -198,6 +210,8 @@ export default function BookImport() { setApplyProgress(cache.applyProgress); setApplyError(cache.applyError); setIsApplyComplete(cache.isApplyComplete); + setExtractMode(cache.extractMode ?? 'tail'); + setTailChapterCount(cache.tailChapterCount ?? 10); setApplyMessage( cache.applyMessage || (cache.applyProgress > 0 && !cache.isApplyComplete ? '已恢复页面缓存,请重新点击“确认导入”继续。' @@ -242,6 +256,8 @@ export default function BookImport() { applyMessage, applyError, isApplyComplete, + extractMode, + tailChapterCount, cachedAt: Date.now(), }); }, [ @@ -253,6 +269,8 @@ export default function BookImport() { applyMessage, applyError, isApplyComplete, + extractMode, + tailChapterCount, ]); useEffect(() => { @@ -325,12 +343,12 @@ export default function BookImport() { setPreview(null); setTaskStatus(null); - const normalizedTailChapterCount = Math.max(5, Math.ceil(tailChapterCount / 5) * 5); - const normalizedExtractMode = normalizedTailChapterCount > 50 ? 'full' : extractMode; + setExtractMode(effectiveExtractMode); + setTailChapterCount(normalizedTailChapterCount); const response = await bookImportApi.createTask({ file, - extract_mode: normalizedExtractMode, + extract_mode: effectiveExtractMode, tail_chapter_count: normalizedTailChapterCount, }); @@ -700,6 +718,14 @@ export default function BookImport() { + {rangeLocked && ( + + )}