Merge branch 'develop' of https://github.com/HBAI-Ltd/Toonflow-app into develop

This commit is contained in:
ACT丶流星雨 2026-04-12 17:42:00 +08:00
commit 077a62073c
6 changed files with 20 additions and 22 deletions

View File

@ -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<number, string> = {};
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,

View File

@ -7,6 +7,9 @@ import axios from "axios";
const router = express.Router();
async function urlToBase64(imageUrl: string): Promise<string> {
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");

View File

@ -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<typeof assetItemSchema>;
@ -142,7 +141,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;
}

View File

@ -37,14 +37,18 @@ export default router.post(
}),
async (req, res) => {
const { projectId, scriptId } = req.body;
const projectData = await u.db("o_project").where("id", projectId).select("id", "videoModel").first();
const projectData = await u.db("o_project").where("id", projectId).select("id", "videoModel","mode").first();
if (!projectData?.videoModel) {
return res.status(400).json(success("项目未配置视频模型"));
}
const [videoId, videoModelName] = projectData.videoModel.split(":");
const models = await u.vendor.getModelList(videoId);
const findData = models.find((i: any) => i.modelName == videoModelName);
const isRef = findData.mode.every((i: any) => Array.isArray(i));
let videoMode = ""
try{
videoMode = JSON.parse(projectData?.mode ?? "")
}catch(e){
videoMode = projectData?.mode ?? ""
}
const isRef = Array.isArray(videoMode) ? true : false;
const storyboardList = await u.db("o_storyboard").where({ scriptId, projectId }).orderBy("index", "asc");
await Promise.all(
@ -105,7 +109,6 @@ export default router.post(
);
}
const id = await u.db("o_project").where({ id: projectId }).select("id").first();
const trackData = await u.db("o_videoTrack").where({ projectId, scriptId });
const videoList = await u.db("o_video").whereIn(
"videoTrackId",

View File

@ -1,4 +1,4 @@
// @db-hash 9248d7bcfe0a1bc57e5b9bc33d8c7d83
// @db-hash 3296433eb24314b094ac5d3839c049c5
//该文件由脚本自动生成,请勿手动修改
export interface memories {

View File

@ -50,7 +50,9 @@ class OSS {
await this.ensureInit();
const safePath = normalizeUserPath(userRelPath);
// URL 始终使用 /,所以这里需要将系统分隔符转回 /
let url = `http://127.0.0.1:10588/${prefix}/`;
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("/")}`;
}