打开 音频

This commit is contained in:
zhishi 2026-04-28 14:16:46 +08:00
parent ab5d1ad462
commit 1290899d34
2 changed files with 21 additions and 17 deletions

View File

@ -7,13 +7,16 @@ const router = express.Router();
// 获取生成图片 // 获取生成图片
export default router.post( export default router.post(
"/", "/",
validateFields({ validateFields({
url: z.string() url: z.string(),
}), }),
async (req, res) => { async (req, res) => {
const { url } = req.body let { url } = req.body;
const bigImageUrl = await u.oss.getFileUrl(u.replaceUrl(url)) if (url.startsWith("/oss/")) {
res.status(200).send(success(bigImageUrl)); url = u.replaceUrl(url).replace("/smallImage", "");
}, }
const bigImageUrl = await u.oss.getFileUrl(u.replaceUrl(url));
res.status(200).send(success(bigImageUrl));
},
); );

View File

@ -27,6 +27,7 @@ export default router.post(
) )
.where("o_assets.projectId", projectId) .where("o_assets.projectId", projectId)
.andWhere("o_assets.type", "<>", "clip") .andWhere("o_assets.type", "<>", "clip")
.andWhere("o_assets.type", "<>", "audio")
.andWhere("o_assets.assetsId", null) .andWhere("o_assets.assetsId", null)
.modify((qb) => { .modify((qb) => {
if (type && type.length > 0) qb.whereIn("o_assets.type", type); if (type && type.length > 0) qb.whereIn("o_assets.type", type);
@ -34,16 +35,16 @@ export default router.post(
.orderByRaw(`CASE o_assets.type WHEN 'role' THEN 1 WHEN 'scene' THEN 2 WHEN 'tool' THEN 3 ELSE 4 END`); .orderByRaw(`CASE o_assets.type WHEN 'role' THEN 1 WHEN 'scene' THEN 2 WHEN 'tool' THEN 3 ELSE 4 END`);
const assets2AudioData = await u const assets2AudioData = await u
.db("o_assetsRole2Audio") .db("o_assetsRole2Audio")
.leftJoin("o_assets", "o_assets.id", "o_assetsRole2Audio.assetsRoleId") .leftJoin("o_assets", "o_assets.id", "o_assetsRole2Audio.assetsAudioId")
.whereIn( .whereIn(
"assetsRoleId", "o_assetsRole2Audio.assetsRoleId",
data.map((i:any) => i.id!), data.map((i: any) => i.id!),
) )
.select( "o_assets.id", "o_assets.name"); .select("o_assets.id", "o_assets.name", "o_assetsRole2Audio.assetsRoleId");
const repleAssets:Record<number,{id:number;name:string}[]> = {}; const repleAssets: Record<number, { id: number; name: string }[]> = {};
assets2AudioData.forEach((item) => { assets2AudioData.forEach((item) => {
if (!repleAssets[item.id]) repleAssets[item.id] = [item]; if (!repleAssets[item.assetsRoleId]) repleAssets[item.assetsRoleId] = [item];
else repleAssets[item.id].push(item); else repleAssets[item.assetsRoleId].push(item);
}); });
const result = await Promise.all( const result = await Promise.all(
data.map(async (parent: any) => { data.map(async (parent: any) => {
@ -58,7 +59,7 @@ export default router.post(
...parent, ...parent,
filePath: parent.filePath && (await u.oss.getSmallImageUrl(parent.filePath!)), filePath: parent.filePath && (await u.oss.getSmallImageUrl(parent.filePath!)),
historyImages: historyImagesWithUrl, historyImages: historyImagesWithUrl,
relepedAudio:repleAssets[parent.id] ?? [] relepedAudio: repleAssets[parent.id] ?? [],
}; };
}), }),
); );