no message
This commit is contained in:
parent
d2ce2b2c7b
commit
9669da6754
@ -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({
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
|
||||
10
src/types/database.d.ts
vendored
10
src/types/database.d.ts
vendored
@ -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;
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -56,6 +56,8 @@ export default async (input: ImageConfig, config: AIConfig): Promise<string> =>
|
||||
},
|
||||
},
|
||||
});
|
||||
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<string> =>
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user