修复bug

This commit is contained in:
zhishi 2026-04-06 23:50:59 +08:00
parent 92a3af229d
commit 85a8fd0518

View File

@ -50,6 +50,29 @@ export default router.post(
}
}),
);
const assetsIds = images.map((i) => {
if (i._type == "storyboard") {
return i.associateAssetsIds;
}
});
const setIds = new Set(assetsIds.filter(Boolean).flat());
const assetsData = await u
.db("o_assets")
.leftJoin("o_image", "o_assets.imageId", "o_image.id")
.where("o_assets.id", "in", Array.from(setIds))
.select("o_assets.id", "o_image.filePath", "o_assets.name", "o_assets.type");
await Promise.all(
assetsData.map(async (i) => {
if (i.filePath) {
i.filePath = await u.oss.getFileUrl(i.filePath);
}
}),
);
const assetsRecord: Record<number, any> = {};
assetsData.forEach((i) => {
assetsRecord[i.id] = i;
});
// 拆分 assets 和 storyboard
const assets: any[] = [];
@ -62,7 +85,7 @@ export default router.post(
type: item.type,
name: item.name,
});
if (item._type === "storyboard")
if (item._type === "storyboard") {
storyboard.push({
videoDesc: item.videoDesc,
prompt: item.prompt,
@ -71,7 +94,22 @@ export default router.post(
associateAssetsIds: item.associateAssetsIds,
shouldGenerateImage: item.shouldGenerateImage,
});
if (item.associateAssetsIds && item.associateAssetsIds.length) {
item.associateAssetsIds.forEach((i: number) => {
const data = assetsRecord[i];
const extingIndex = assets.find((sub) => sub.id == data.id);
if (data && !extingIndex) {
assets.push({
id: data.id,
type: data.type,
name: data.name,
});
}
});
}
}
}
const [id, modelData] = model.split(":");
const projectData = await u.db("o_project").select("*").where({ id: projectId }).first();
const videoPrompt = await u.db("o_prompt").where("type", "videoPromptGeneration").first();