From 2b6a185cf1841c7a9869b2ba779bc3997f023439 Mon Sep 17 00:00:00 2001 From: a12110 Date: Fri, 10 Apr 2026 16:00:08 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9:=20web/docker=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E4=B8=8B=E8=B5=84=E6=BA=90=E8=BF=94=E5=9B=9E=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E4=BB=8E=E5=8E=9F=E6=9C=AC=E7=9A=84=E5=9B=BA=E5=AE=9A?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=E4=BF=AE=E6=94=B9=E4=B8=BA=E7=9B=B8=E5=AF=B9?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/oss.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/oss.ts b/src/utils/oss.ts index a5088f5..bfeb0a2 100644 --- a/src/utils/oss.ts +++ b/src/utils/oss.ts @@ -50,7 +50,7 @@ class OSS { await this.ensureInit(); const safePath = normalizeUserPath(userRelPath); // URL 始终使用 /,所以这里需要将系统分隔符转回 / - let url = `http://127.0.0.1:10588/${prefix}/`; + let url = `/${prefix}/`; if (isEletron()) url = `http://localhost:${process.env.PORT}/${prefix}/`; return `${url}${safePath.split(path.sep).join("/")}`; } From 7486c419f115907b27c47e62daedcc2e2980fbad Mon Sep 17 00:00:00 2001 From: a12110 Date: Fri, 10 Apr 2026 17:23:24 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=94=B9:=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=9B=BE=E5=83=8F=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=B8=8D=E5=BF=85=E8=A6=81=E7=9A=84urlToBase?= =?UTF-8?q?64=E5=87=BD=E6=95=B0=E8=B0=83=E7=94=A8=EF=BC=8C=E7=9B=B4?= =?UTF-8?q?=E6=8E=A5=E4=BD=BF=E7=94=A8getImageBase64=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../production/assets/batchGenerateAssetsImage.ts | 15 +++------------ .../production/editImage/generateFlowImage.ts | 3 +++ .../production/storyboard/batchGenerateImage.ts | 3 +-- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/routes/production/assets/batchGenerateAssetsImage.ts b/src/routes/production/assets/batchGenerateAssetsImage.ts index d7ec5d8..6178ee1 100644 --- a/src/routes/production/assets/batchGenerateAssetsImage.ts +++ b/src/routes/production/assets/batchGenerateAssetsImage.ts @@ -5,7 +5,6 @@ import sharp from "sharp"; import { success } from "@/lib/responseFormat"; import { validateFields } from "@/middleware/middleware"; import { Output } from "ai"; -import { urlToBase64 } from "@/utils/vm"; const router = express.Router(); export default router.post( @@ -28,14 +27,6 @@ export default router.post( .leftJoin("o_image", "o_assets.imageId", "o_image.id") .whereIn("o_assets.id", parentIds as number[]) .select("o_assets.id", "o_image.filePath", "o_assets.describe"); - const assetsSrcArr = await Promise.all( - parentAssetsData.map(async (item) => { - return { - src: await u.oss.getFileUrl(item.filePath), - id: item.id, - }; - }), - ); assetsDataArr.forEach((i: any) => { const parent = parentAssetsData.find((item) => item.id === i.assetsId); if (parent) { @@ -43,8 +34,8 @@ export default router.post( } }); const imageUrlRecord: Record = {}; - assetsSrcArr.forEach((item) => { - imageUrlRecord[item.id] = item.src; + parentAssetsData.forEach((item) => { + if (item.filePath) imageUrlRecord[item.id] = item.filePath; }); const rolePrompt = u.getArtPrompt(projectSettingData!.artStyle!, "art_skills", "art_character_derivative"); const toolPrompt = u.getArtPrompt(projectSettingData!.artStyle!, "art_skills", "art_prop_derivative"); @@ -92,7 +83,7 @@ export default router.post( ], }); - const imageBase64 = imageUrlRecord[item.assetsId!] ? await urlToBase64(imageUrlRecord[item.assetsId!]) : null; + const imageBase64 = imageUrlRecord[item.assetsId!] ? await u.oss.getImageBase64(imageUrlRecord[item.assetsId!]) : null; try { const repeloadObj = { prompt: text, diff --git a/src/routes/production/editImage/generateFlowImage.ts b/src/routes/production/editImage/generateFlowImage.ts index 3c4a1b5..c05937b 100644 --- a/src/routes/production/editImage/generateFlowImage.ts +++ b/src/routes/production/editImage/generateFlowImage.ts @@ -7,6 +7,9 @@ import axios from "axios"; const router = express.Router(); async function urlToBase64(imageUrl: string): Promise { + if (imageUrl.startsWith("/oss/")) { + return await u.oss.getImageBase64(u.replaceUrl(imageUrl)); + } const response = await axios.get(imageUrl, { responseType: "arraybuffer" }); const contentType = response.headers["content-type"] || "image/png"; const base64 = Buffer.from(response.data, "binary").toString("base64"); diff --git a/src/routes/production/storyboard/batchGenerateImage.ts b/src/routes/production/storyboard/batchGenerateImage.ts index cf19a06..d75fa6d 100644 --- a/src/routes/production/storyboard/batchGenerateImage.ts +++ b/src/routes/production/storyboard/batchGenerateImage.ts @@ -5,7 +5,6 @@ import sharp from "sharp"; import { error, success } from "@/lib/responseFormat"; import { validateFields } from "@/middleware/middleware"; import { Output, tool } from "ai"; -import { urlToBase64 } from "@/utils/vm"; import { assetItemSchema } from "@/agents/productionAgent/tools"; const router = express.Router(); export type AssetData = z.infer; @@ -143,7 +142,7 @@ async function getAssetsImageBase64(imageIds: number[]) { const filePath = id2Path.get(id); if (filePath) { try { - return await urlToBase64(await u.oss.getFileUrl(filePath)); + return await u.oss.getImageBase64(filePath); } catch { return null; } From 6e825f6c8a933cd090af0199c4b66d162ddd6297 Mon Sep 17 00:00:00 2001 From: a12110 Date: Fri, 10 Apr 2026 23:27:33 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0:=20=E5=A2=9E=E5=BC=BAoss?= =?UTF-8?q?Url=E8=BF=94=E5=9B=9E=E5=81=A5=E5=A3=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 + .gitignore | 1 - src/env.ts | 8 ++++++++ src/types/database.d.ts | 36 +----------------------------------- src/utils/oss.ts | 2 ++ 5 files changed, 12 insertions(+), 36 deletions(-) create mode 100644 .env diff --git a/.env b/.env new file mode 100644 index 0000000..4ea20d2 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +ossURL= \ No newline at end of file diff --git a/.gitignore b/.gitignore index f5aa258..1575956 100644 --- a/.gitignore +++ b/.gitignore @@ -17,7 +17,6 @@ _.log report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json # dotenv environment variable files -.env .env.development.local .env.test.local .env.production.local diff --git a/src/env.ts b/src/env.ts index db8f322..ca3c960 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,3 +1,11 @@ +import dotenv from "dotenv"; +import path from "node:path"; + +dotenv.config({ + path: path.resolve(process.cwd(), ".env"), +}); + + // 判断是否为打包后的 Electron 环境 const isElectron = typeof process.versions?.electron !== "undefined"; let isPackaged = false; diff --git a/src/types/database.d.ts b/src/types/database.d.ts index 8adea86..2a9745d 100644 --- a/src/types/database.d.ts +++ b/src/types/database.d.ts @@ -1,37 +1,6 @@ -// @db-hash 6cd709d9bdfe00c4dc87961a8ebba149 +// @db-hash 3296433eb24314b094ac5d3839c049c5 //该文件由脚本自动生成,请勿手动修改 -export interface _o_project_old_20260404 { - 'artStyle'?: string | null; - 'createTime'?: number | null; - 'directorManual'?: string | null; - 'id'?: number | null; - 'imageModel'?: string | null; - 'imageQuality'?: string | null; - 'intro'?: string | null; - 'mode'?: string | null; - 'name'?: string | null; - 'projectType'?: string | null; - 'type'?: string | null; - 'userId'?: number | null; - 'videoModel'?: string | null; - 'videoRatio'?: string | null; -} -export interface _o_prompt_old_20260406 { - 'data'?: string | null; - 'id'?: number; - 'name'?: string | null; - 'type'?: string | null; - 'useData'?: string | null; -} -export interface _o_prompt_old_20260406_1 { - 'data'?: string | null; - 'id'?: number; - 'name'?: string | null; - 'TEXT'?: any | null; - 'type'?: string | null; - 'useData'?: string | null; -} export interface memories { 'content': string; 'createTime': number; @@ -263,9 +232,6 @@ export interface o_videoTrack { } export interface DB { - "_o_project_old_20260404": _o_project_old_20260404; - "_o_prompt_old_20260406": _o_prompt_old_20260406; - "_o_prompt_old_20260406_1": _o_prompt_old_20260406_1; "memories": memories; "o_agentDeploy": o_agentDeploy; "o_agentWorkData": o_agentWorkData; diff --git a/src/utils/oss.ts b/src/utils/oss.ts index bfeb0a2..e019a88 100644 --- a/src/utils/oss.ts +++ b/src/utils/oss.ts @@ -51,6 +51,8 @@ class OSS { const safePath = normalizeUserPath(userRelPath); // URL 始终使用 /,所以这里需要将系统分隔符转回 / let url = `/${prefix}/`; + if (!process.env.ossURL || process.env.ossURL != "") url = process.env.ossURL + `/${prefix}/`; + // if (process.env.NODE_ENV == "dev") url = `http://localhost:10588/${prefix}/`; if (isEletron()) url = `http://localhost:${process.env.PORT}/${prefix}/`; return `${url}${safePath.split(path.sep).join("/")}`; } From b74aba809798a9c44f77121acae8171af5450da9 Mon Sep 17 00:00:00 2001 From: a12110 Date: Fri, 10 Apr 2026 23:29:00 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0:=20=E5=A2=9E=E5=BC=BAoss?= =?UTF-8?q?Url=E8=BF=94=E5=9B=9E=E5=81=A5=E5=A3=AE=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/oss.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/oss.ts b/src/utils/oss.ts index e019a88..d53dbfd 100644 --- a/src/utils/oss.ts +++ b/src/utils/oss.ts @@ -52,7 +52,7 @@ class OSS { // URL 始终使用 /,所以这里需要将系统分隔符转回 / let url = `/${prefix}/`; if (!process.env.ossURL || process.env.ossURL != "") url = process.env.ossURL + `/${prefix}/`; - // if (process.env.NODE_ENV == "dev") url = `http://localhost:10588/${prefix}/`; + if (process.env.NODE_ENV == "dev") url = `http://localhost:10588/${prefix}/`; if (isEletron()) url = `http://localhost:${process.env.PORT}/${prefix}/`; return `${url}${safePath.split(path.sep).join("/")}`; } From ba2aff52ef1f1bce602c01dfc873af110461c24c Mon Sep 17 00:00:00 2001 From: a12110 Date: Sun, 12 Apr 2026 16:13:35 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0:=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E9=9D=9EElectron=E7=8E=AF=E5=A2=83=E4=B8=8B=20?= =?UTF-8?q?=E6=89=8D=E5=8A=A0=E8=BD=BD=20.env=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E7=8E=AF=E5=A2=83=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/env.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/env.ts b/src/env.ts index ca3c960..09af65c 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,11 +1,6 @@ import dotenv from "dotenv"; import path from "node:path"; -dotenv.config({ - path: path.resolve(process.cwd(), ".env"), -}); - - // 判断是否为打包后的 Electron 环境 const isElectron = typeof process.versions?.electron !== "undefined"; let isPackaged = false; @@ -14,6 +9,13 @@ if (isElectron) { isPackaged = app.isPackaged; } +// 仅在非 Electron 环境加载 .env(例如 Docker / Web 后端) +if (!isElectron) { + dotenv.config({ + path: path.resolve(process.cwd(), ".env"), + }); +} + //加载环境变量(打包环境默认使用 prod) const env = process.env.NODE_ENV; if (!env) { From b7b165c860c17fc3cfff76f2edd3b6a3506041c1 Mon Sep 17 00:00:00 2001 From: a12110 Date: Sun, 12 Apr 2026 17:00:33 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E6=9B=B4=E6=96=B0:=20=E5=88=A0=E9=99=A4=20?= =?UTF-8?q?=E9=80=9A=E8=BF=87=20.env=20=E8=AF=BB=E5=85=A5=20ossurl=20?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 - .gitignore | 1 + src/env.ts | 10 ---------- src/utils/oss.ts | 2 +- 4 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index 4ea20d2..0000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -ossURL= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 1575956..f5aa258 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ _.log report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json # dotenv environment variable files +.env .env.development.local .env.test.local .env.production.local diff --git a/src/env.ts b/src/env.ts index 09af65c..db8f322 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,6 +1,3 @@ -import dotenv from "dotenv"; -import path from "node:path"; - // 判断是否为打包后的 Electron 环境 const isElectron = typeof process.versions?.electron !== "undefined"; let isPackaged = false; @@ -9,13 +6,6 @@ if (isElectron) { isPackaged = app.isPackaged; } -// 仅在非 Electron 环境加载 .env(例如 Docker / Web 后端) -if (!isElectron) { - dotenv.config({ - path: path.resolve(process.cwd(), ".env"), - }); -} - //加载环境变量(打包环境默认使用 prod) const env = process.env.NODE_ENV; if (!env) { diff --git a/src/utils/oss.ts b/src/utils/oss.ts index d53dbfd..e95ed21 100644 --- a/src/utils/oss.ts +++ b/src/utils/oss.ts @@ -51,7 +51,7 @@ class OSS { const safePath = normalizeUserPath(userRelPath); // URL 始终使用 /,所以这里需要将系统分隔符转回 / let url = `/${prefix}/`; - if (!process.env.ossURL || process.env.ossURL != "") url = process.env.ossURL + `/${prefix}/`; + if (process.env.ossURL && process.env.ossURL !== "") url = process.env.ossURL + `/${prefix}/`; if (process.env.NODE_ENV == "dev") url = `http://localhost:10588/${prefix}/`; if (isEletron()) url = `http://localhost:${process.env.PORT}/${prefix}/`; return `${url}${safePath.split(path.sep).join("/")}`;