diff --git a/src/routes/production/storyboard/addStoryboard.ts b/src/routes/production/storyboard/addStoryboard.ts index 0aa9e7a..54aebf1 100644 --- a/src/routes/production/storyboard/addStoryboard.ts +++ b/src/routes/production/storyboard/addStoryboard.ts @@ -38,7 +38,7 @@ export default router.post( filePath: new URL(src).pathname, trackId, videoDesc, - shouldGenerateImage, + shouldGenerateImage: src ? 1 : 0, scriptId: scriptId, projectId: projectId, }); diff --git a/src/routes/production/storyboard/batchGenerateImage.ts b/src/routes/production/storyboard/batchGenerateImage.ts index a47ef8c..057b6d2 100644 --- a/src/routes/production/storyboard/batchGenerateImage.ts +++ b/src/routes/production/storyboard/batchGenerateImage.ts @@ -33,7 +33,9 @@ export default router.post( if (!storyboardIds || storyboardIds.length === 0) return res.status(400).send(error("storyboardIds不能为空")); // 当没有 storyboardIds 时,通过 AI 生成新的分镜面板数据 let finalStoryboardIds: number[] = storyboardIds || []; - await u.db("o_storyboard").whereIn("id", finalStoryboardIds).where("scriptId", scriptId).update({ state: "生成中" }); + // shouldGenerateImage === 0 的分镜标记为「未生成」,其余标记为「生成中」 + await u.db("o_storyboard").whereIn("id", finalStoryboardIds).where("scriptId", scriptId).where("shouldGenerateImage", 0).update({ state: "未生成" }); + await u.db("o_storyboard").whereIn("id", finalStoryboardIds).where("scriptId", scriptId).whereNot("shouldGenerateImage", 0).update({ state: "生成中" }); const projectSettingData = await u.db("o_project").where("id", projectId).select("imageModel", "imageQuality", "artStyle").first(); @@ -61,6 +63,8 @@ export default router.post( associateAssetsIds: assetRecord[i.id!], src: null, state: i.state, + videoDesc: i.videoDesc, + shouldGenerateImage: i.shouldGenerateImage, })), ), ); @@ -103,9 +107,10 @@ export default router.post( }); }; - // 按 concurrentCount 控制并发数,分批执行 - for (let i = 0; i < storyboardData.length; i += concurrentCount) { - const batch = storyboardData.slice(i, i + concurrentCount); + // 按 concurrentCount 控制并发数,分批执行;跳过 shouldGenerateImage === 0 的分镜 + const generateList = storyboardData.filter((item) => item.shouldGenerateImage !== 0); + for (let i = 0; i < generateList.length; i += concurrentCount) { + const batch = generateList.slice(i, i + concurrentCount); await Promise.all(batch.map(generateTask)); } }, diff --git a/src/routes/production/storyboard/updateStoryboardUrl.ts b/src/routes/production/storyboard/updateStoryboardUrl.ts index 95294f9..708f43f 100644 --- a/src/routes/production/storyboard/updateStoryboardUrl.ts +++ b/src/routes/production/storyboard/updateStoryboardUrl.ts @@ -22,6 +22,7 @@ export default router.post( filePath: new URL(url).pathname, flowId, state: "已完成", + shouldGenerateImage:url ? 1 : 0 }); res.status(200).send(success({ message: "更新分镜成功" })); },