diff --git a/src/routes/assets/getMaterialData.ts b/src/routes/assets/getMaterialData.ts index 06e7c64..d3c14cc 100644 --- a/src/routes/assets/getMaterialData.ts +++ b/src/routes/assets/getMaterialData.ts @@ -45,7 +45,7 @@ export default router.post( id: row.id, filePath: row.filePath ? await u.oss.getFileUrl(row.filePath) : "", selected: selectedIds.has(row.id), - storyboard: row.storyboardId, + videoParametersId: row.videoParametersId, })), ); diff --git a/src/routes/assetsGenerate/batchPolishAssetsPrompt.ts b/src/routes/assetsGenerate/batchPolishAssetsPrompt.ts index 130f7c0..56a29ce 100644 --- a/src/routes/assetsGenerate/batchPolishAssetsPrompt.ts +++ b/src/routes/assetsGenerate/batchPolishAssetsPrompt.ts @@ -107,25 +107,21 @@ export default router.post( if (!visualManual) return res.status(500).send(error("视觉手册未定义")); findItemByName(result, item.name, config.itemType); - const systemPrompt = ` - 请根据以下参数生成${config.label}提示词: - - **基础参数:** - - 小说类型: ${project?.type || "未指定"} - - 小说背景: ${project?.intro || "未指定"} - - **${config.nameLabel}设定:** - - ${config.nameLabel}名称:${item.name}, - - ${config.nameLabel}描述:${item.describe}, - - 请严格按照skill规范生成${item.type === "role" ? "人物角色四视图" : config.label}提示词。 - ${visualManual} - `; + const systemPrompt = visualManual; try { const { _output } = (await u.Ai.Text("universalAi").invoke({ system: systemPrompt, - messages: [{ role: "user", content: "小说原文" + novelText }], + messages: [ + { + role: "user", + content: ` + **基础参数:** + **${config.nameLabel}设定:** + - ${config.nameLabel}名称:${item.name}, + - ${config.nameLabel}描述:${item.describe},`, + }, + ], })) as any; if (!_output) { diff --git a/src/routes/assetsGenerate/polishAssetsPrompt.ts b/src/routes/assetsGenerate/polishAssetsPrompt.ts index bb12bc5..95ea549 100644 --- a/src/routes/assetsGenerate/polishAssetsPrompt.ts +++ b/src/routes/assetsGenerate/polishAssetsPrompt.ts @@ -101,25 +101,20 @@ export default router.post( const novelData = (await u.db("o_novel").whereIn("chapterIndex", [1]).select("*")) as NovelChapter[]; const novelText = mergeNovelText(novelData); - const systemPrompt = ` - 请根据以下参数生成${config.label}提示词: - - **基础参数:** - - 小说类型: ${project?.type || "未指定"} - - 小说背景: ${project?.intro || "未指定"} - - **${config.nameLabel}设定:** - - ${config.nameLabel}名称:${name}, - - ${config.nameLabel}描述:${describe}, - - 请严格按照skill规范生成${type === "role" ? "人物角色四视图" : config.label}提示词 - ${visualManual}。 - `; + const systemPrompt = visualManual; try { const { _output } = (await u.Ai.Text("universalAi").invoke({ system: systemPrompt, - messages: [{ role: "user", content: "小说原文" + novelText }], + messages: [ + { + role: "user", + content: `**基础参数:** + **${config.nameLabel}设定:** + - ${config.nameLabel}名称:${name}, + - ${config.nameLabel}描述:${describe},`, + }, + ], })) as any; if (!_output) return res.status(500).send("失败"); diff --git a/src/routes/production/getFlowData.ts b/src/routes/production/getFlowData.ts index ffa25b5..46a859d 100644 --- a/src/routes/production/getFlowData.ts +++ b/src/routes/production/getFlowData.ts @@ -73,11 +73,24 @@ export default router.post( storyboard: [], //todo:矫正workbench数据 workbench: { - name: scriptData?.name ?? "", - duration: "01:03", - resolution: "1920×1080", - fps: "30fps", - gradient: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)", + videoList: [ + { + id: 1, + prompt: "动起来", + filePath: await u.oss.getFileUrl("/artStyle/5d96256a-1610-43a6-a469-c2385cc2287e.jpg"), + duration: 4, + scriptId: 1, + selectedVideoId: 1, + }, + { + id: 2, + prompt: "跳起来", + filePath: await u.oss.getFileUrl("/artStyle/5d96256a-1610-43a6-a469-c2385cc2287e.jpg"), + duration: 4, + scriptId: 1, + selectedVideoId: 1, + }, + ], }, //todo:矫正封面数据 poster: { diff --git a/src/routes/production/getProductionData.ts b/src/routes/production/getProductionData.ts index 1c55f08..90b725e 100644 --- a/src/routes/production/getProductionData.ts +++ b/src/routes/production/getProductionData.ts @@ -7,36 +7,25 @@ const router = express.Router(); export default router.post( "/", validateFields({ - scriptId: z.number(), - projectId: z.number(), + ids: z.array(z.number()), }), async (req, res) => { - const { scriptId, projectId } = req.body; - - //查询分镜数据 - const storyboards = await u.db("o_storyboard").where("o_storyboard.scriptId", scriptId).select("*").orderBy("index", "asc"); - - //查询项目默认的视频模型 - const project = await u.db("o_project").where("id", projectId).first(); - - const storyboardsList = await Promise.all( - storyboards.map(async (item) => { - return { - ...item, - model: project?.videoModel || null, - filePath: item.filePath ? await u.oss.getFileUrl(item.filePath) : null, - }; - }), - ); - - const storyboardIds = storyboardsList.map((s) => s.id as number); + const { ids } = req.body; //查询分镜配置 - const storyboardConfigs = await u.db("o_videoConfig").whereIn("storyboardId", storyboardIds).select("*"); - const storyboardConfigsList = await Promise.all( - storyboardConfigs.map(async (item) => { - if (item.data) { - const parsedData = JSON.parse(item.data); + const storyboardConfigs = await u.db("o_videoConfig").whereIn("storyboardId", ids).select("*"); + + //查询视频数据 + const videos = await u.db("o_video").whereIn("storyboardId", ids).select("*"); + + //组装数据 + const data = await Promise.all( + ids.map(async (storyboardId: number) => { + // 处理配置 + const configRow = storyboardConfigs.find((item) => item.storyboardId === storyboardId) || null; + let config = null; + if (configRow?.data) { + const parsedData = JSON.parse(configRow.data); const dataWithFilePath = await Promise.all( parsedData.map(async (d: { type: string; id: number }) => { if (d.type === "assets" && d.id) { @@ -61,35 +50,25 @@ export default router.post( return null; }), ); - - return { - ...item, - data: dataWithFilePath, - }; + config = { ...configRow, data: dataWithFilePath }; } - }), - ); - //查询视频数据 - const videos = await u.db("o_video").whereIn("storyboardId", storyboardIds).select("*"); - const videosList = await Promise.all( - videos.map(async (item) => { + // 处理视频 + const storyboardVideos = videos.filter((v) => v.storyboardId === storyboardId); + const videosList = await Promise.all( + storyboardVideos.map(async (item) => ({ + ...item, + filePath: item.filePath ? await u.oss.getFileUrl(item.filePath) : null, + })), + ); + return { - ...item, - filePath: item.filePath ? await u.oss.getFileUrl(item.filePath) : null, + id: storyboardId, + config, + videos: videosList, }; }), ); - - //组装数据 - const data = storyboardsList.map((storyboard) => { - const config = storyboardConfigsList.find((item) => item?.storyboardId === storyboard.id) || null; - return { - ...storyboard, - config, - videos: videosList.filter((video) => video.storyboardId === storyboard.id), - }; - }); return res.status(200).send(success(data)); }, ); diff --git a/src/routes/production/workbench/videoPolling.ts b/src/routes/production/workbench/videoPolling.ts index 2d68b51..897c3d0 100644 --- a/src/routes/production/workbench/videoPolling.ts +++ b/src/routes/production/workbench/videoPolling.ts @@ -8,12 +8,12 @@ const router = express.Router(); export default router.post( "/", validateFields({ - scriptId: z.number(), + id: z.number(), specifyIds: z.array(z.number()), }), async (req, res) => { - const { scriptId, specifyIds } = req.body; - const data = await u.db("o_video").where("scriptId", scriptId).whereIn("id", specifyIds).andWhere("state", "生成中").select("*"); + const { id, specifyIds } = req.body; + const data = await u.db("o_video").where("id", id).whereIn("id", specifyIds).andWhere("state", "生成中").select("*"); res.status(200).send(success(data)); }, -); \ No newline at end of file +);