From 9669da6754ba510d73c77e0331407ccc434214ce Mon Sep 17 00:00:00 2001 From: zhishi <1951671751@qq.com> Date: Tue, 10 Feb 2026 19:28:42 +0800 Subject: [PATCH] no message --- src/routes/assets/generateAssets.ts | 6 ++++++ src/routes/assets/saveAssets.ts | 8 ++++---- src/types/database.d.ts | 10 ++++++---- src/utils/ai/image/index.ts | 2 ++ src/utils/ai/image/owned/other.ts | 8 ++++++++ 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/routes/assets/generateAssets.ts b/src/routes/assets/generateAssets.ts index 9d01e9d..7889f1a 100644 --- a/src/routes/assets/generateAssets.ts +++ b/src/routes/assets/generateAssets.ts @@ -139,6 +139,7 @@ export default router.post( let insertType; const match = contentStr.match(/base64,([A-Za-z0-9+/=]+)/); let buffer = Buffer.from(match && match.length >= 2 ? match[1]! : contentStr!, "base64"); + if (type != "storyboard") { //添加文本 // buffer = await imageAddText(name, buffer); @@ -156,6 +157,11 @@ export default router.post( insertType = "道具"; imagePath = `/${projectId}/props/${uuidv4()}.jpg`; } + if (type == "storyboard") { + insertType = "分镜"; + imagePath = `/${projectId}/storyboard/${uuidv4()}.jpg`; + } + await u.oss.writeFile(imagePath!, buffer); await u.db("t_image").where("id", imageId).update({ diff --git a/src/routes/assets/saveAssets.ts b/src/routes/assets/saveAssets.ts index 0396352..471a10f 100644 --- a/src/routes/assets/saveAssets.ts +++ b/src/routes/assets/saveAssets.ts @@ -46,10 +46,10 @@ export default router.post( } // 检查图片表里是否有这条图片 - const selectedImage = await u.db("t_image").where("filePath", savePath).first(); - if (!selectedImage) { - return res.status(404).send({ success: false, message: "所选图片不存在,请重新生成或选定图片" }); - } + // const selectedImage = await u.db("t_image").where("filePath", savePath).first(); + // if (!selectedImage) { + // return res.status(500).send({ success: false, message: "所选图片不存在,请重新生成或选定图片" }); + // } imageUrl = savePath; } diff --git a/src/types/database.d.ts b/src/types/database.d.ts index c90deda..67c3c9c 100644 --- a/src/types/database.d.ts +++ b/src/types/database.d.ts @@ -1,7 +1,8 @@ -// @db-hash 5a633f2d45df5d971905dd32c0ac9880 +// @db-hash 5a1cbe86324cb073c1931fc53c56725f //该文件由脚本自动生成,请勿手动修改 -export interface _t_video_old_20260131 { +export interface _t_video_old_20260210 { + 'aiConfigId'?: number | null; 'configId'?: number | null; 'filePath'?: string | null; 'firstFrame'?: string | null; @@ -52,7 +53,6 @@ export interface t_config { 'manufacturer'?: string | null; 'model'?: string | null; 'modelType'?: string | null; - 'name'?: string | null; 'type'?: string | null; 'userId'?: number | null; } @@ -139,6 +139,7 @@ export interface t_user { export interface t_video { 'aiConfigId'?: number | null; 'configId'?: number | null; + 'errorReason'?: string | null; 'filePath'?: string | null; 'firstFrame'?: string | null; 'id'?: number; @@ -151,6 +152,7 @@ export interface t_video { 'time'?: number | null; } export interface t_videoConfig { + 'aiConfigId'?: number | null; 'audioEnabled'?: number | null; 'createTime'?: number | null; 'duration'?: number | null; @@ -170,7 +172,7 @@ export interface t_videoConfig { } export interface DB { - "_t_video_old_20260131": _t_video_old_20260131; + "_t_video_old_20260210": _t_video_old_20260210; "t_aiModelMap": t_aiModelMap; "t_assets": t_assets; "t_chatHistory": t_chatHistory; diff --git a/src/utils/ai/image/index.ts b/src/utils/ai/image/index.ts index 424b834..3054ebd 100644 --- a/src/utils/ai/image/index.ts +++ b/src/utils/ai/image/index.ts @@ -29,6 +29,7 @@ const modelInstance = { } as const; export default async (input: ImageConfig, config: AIConfig) => { + console.log("%c Line:32 🥪 config", "background:#33a5ff", config); const { model, apiKey, baseURL, manufacturer } = { ...config }; if (!config || !config?.model || !config?.apiKey || !config?.manufacturer) throw new Error("请检查模型配置是否正确"); @@ -64,6 +65,7 @@ export default async (input: ImageConfig, config: AIConfig) => { } let imageUrl = await manufacturerFn(input, { model, apiKey, baseURL }); + console.log("%c Line:68 🍷 imageUrl", "background:#4fff4B", imageUrl); if (!input.resType) input.resType = "b64"; if (input.resType === "b64" && imageUrl.startsWith("http")) imageUrl = await urlToBase64(imageUrl); return imageUrl; diff --git a/src/utils/ai/image/owned/other.ts b/src/utils/ai/image/owned/other.ts index 067a0f5..c6b3452 100644 --- a/src/utils/ai/image/owned/other.ts +++ b/src/utils/ai/image/owned/other.ts @@ -56,6 +56,8 @@ export default async (input: ImageConfig, config: AIConfig): Promise => }, }, }); + console.log("%c Line:46 🍌 result", "background:#ea7e5c", result); + if (result.files && result.files.length) { let imageBase64; for (const item of result.files) { @@ -70,22 +72,28 @@ export default async (input: ImageConfig, config: AIConfig): Promise => } const mdMatch = result.text.match(/^!\[.*?\]\((.+?)\)$/); if (mdMatch) { + console.log("%c Line:75 🍎", "background:#42b983"); const imgInfo = mdMatch[1]; const base64InMd = imgInfo.match(/data:image\/[a-z]+;base64,(.+)/); if (base64InMd) { + console.log("%c Line:79 🌮", "background:#ffdd4d"); return imgInfo; } else { + console.log("%c Line:82 🧀", "background:#33a5ff"); return await urlToBase64(imgInfo); } } const base64Match = result.text.match(/base64,([A-Za-z0-9+/=]+)/); + console.log("%c Line:87 🍆 base64Match", "background:#2eafb0", base64Match); if (base64Match) { return "data:image/jpeg;base64," + base64Match[1]; } // 检查是否为图片直链 url if (/^https?:\/\/.*\.(png|jpg|jpeg|gif|webp|bmp)$/i.test(result.text)) { + console.log("%c Line:93 🍪", "background:#93c0a4"); return await urlToBase64(result.text); } + console.log("%c Line:96 🌰", "background:#ffdd4d"); // 默认情况 return result.text; }