From 4decb7a7c7d8446b6a2eb52d88068006e48c96f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=B8=85?= <2944435683> Date: Mon, 23 Mar 2026 18:33:18 +0800 Subject: [PATCH] no message --- src/routes/production/exportImage.ts | 42 ++++++++++++++++--- .../production/workbench/videoPolling.ts | 3 +- src/types/database.d.ts | 4 +- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/src/routes/production/exportImage.ts b/src/routes/production/exportImage.ts index fdddd2c..cfd52ae 100644 --- a/src/routes/production/exportImage.ts +++ b/src/routes/production/exportImage.ts @@ -4,17 +4,49 @@ import { z } from "zod"; import { success } from "@/lib/responseFormat"; import { validateFields } from "@/middleware/middleware"; const router = express.Router(); +import compressing from "compressing"; import { flowDataSchema } from "@/agents/productionAgent/tools"; +import path from "path"; +import getPath from "@/utils/getPath"; export default router.post( "/", validateFields({ - projectId: z.number(), - episodesId: z.number(), - data: flowDataSchema, + shotId: z.array( + z.object({ + id: z.string(), + }), + ), }), async (req, res) => { - const { projectId, episodesId } = req.body; - return res.status(200).send(success()); + const { shotId } = req.body; + const id = shotId.map((item: { id: string }) => item.id); + const data = await u.db("o_storyboard").whereIn("id", id); + const result = await Promise.all( + data.map(async (item) => { + const url = await u.oss.getFileUrl(item.filePath!); + return { ...item, url }; + }), + ); + const zipStream = new compressing.zip.Stream(); + result.forEach((item) => { + const ext = (item.filePath?.split(".").pop() || "png").toLowerCase(); + const absPath = path.join(getPath("oss"), item.filePath!); + zipStream.addEntry(absPath, { relativePath: `${item.title}.${ext}` }); + }); + + const fileName = `分镜.zip`; + const zipFilePath = getPath(["oss", "temp", fileName]); + await new Promise((resolve, reject) => { + const fs = require("fs"); + fs.mkdirSync(getPath(["oss", "temp"]), { recursive: true }); + const writeStream = fs.createWriteStream(zipFilePath); + zipStream.pipe(writeStream); + writeStream.on("finish", resolve); + writeStream.on("error", reject); + }); + + const downloadUrl = `${process.env.OSSURL || "http://127.0.0.1:10588/"}temp/${fileName}`; + res.json(success({ url: downloadUrl })); }, ); diff --git a/src/routes/production/workbench/videoPolling.ts b/src/routes/production/workbench/videoPolling.ts index 3915b1e..09bd3b0 100644 --- a/src/routes/production/workbench/videoPolling.ts +++ b/src/routes/production/workbench/videoPolling.ts @@ -13,8 +13,7 @@ export default router.post( }), async (req, res) => { const { scriptId, specifyIds } = req.body; - console.log("%c Line:16 🍡", "background:#465975"); - const data = await u.db("o_video").where("scriptId", scriptId).whereIn("id", specifyIds).select("*"); + const data = await u.db("o_video").where("scriptId", scriptId).whereIn("id", specifyIds).andWhere("state", "生成中").select("*"); res.status(200).send(success(data)); }, ); diff --git a/src/types/database.d.ts b/src/types/database.d.ts index 7e0021e..745de96 100644 --- a/src/types/database.d.ts +++ b/src/types/database.d.ts @@ -1,4 +1,4 @@ -// @db-hash 3cdc2f747dac456ddd4bbfd877efe991 +// @db-hash 56071dcf512e84c37ffd555806af7162 //该文件由脚本自动生成,请勿手动修改 export interface memories { @@ -79,8 +79,6 @@ export interface o_novel { 'chapterData'?: string | null; 'chapterIndex'?: number | null; 'createTime'?: number | null; - 'event'?: string | null; - 'eventState'?: number | null; 'id'?: number; 'projectId'?: number | null; 'reel'?: string | null;