保存功能

This commit is contained in:
海龙 2025-08-14 21:06:16 +08:00
parent d08140f537
commit 12bb843f13
2 changed files with 29 additions and 24 deletions

View File

@ -2,6 +2,7 @@ import { useState, useCallback, useMemo } from 'react';
import { RoleEntity, VideoSegmentEntity } from '../domain/Entities';
import { RoleEditUseCase } from '../usecase/RoleEditUseCase';
import { getCharacterShots, applyRoleToShots, CharacterReplacement } from '@/api/video_flow';
import { SaveEditUseCase } from '../usecase/SaveEditUseCase';
/**
*
@ -181,30 +182,35 @@ export const useRoleShotServiceHook = (projectId: string,selectRole?:RoleEntity,
});
console.log('newDraftRoleList', newDraftRoleList)
// 循环调用接口,为每个选中的分镜单独调用
shotSelectionList.forEach(async (shot) => {
try {
// 调用应用角色到分镜接口(不等待完成)
applyRoleToShots({
project_id: projectId,
shot_id: shot.id, // 单个分镜ID
character_replacements: characterReplacements,
wait_for_completion: false, // 不等待完成,异步处理
character_draft: JSON.stringify(newDraftRoleList)
}).then(response => {
if (response.successful) {
console.log(`分镜 ${shot.id} 角色替换成功:`, response.data);
} else {
console.error(`分镜 ${shot.id} 角色替换失败:`, response.message);
}
}).catch(error => {
console.error(`分镜 ${shot.id} 角色替换异常:`, error);
});
} catch (error) {
console.error(`分镜 ${shot.id} 角色替换失败:`, error);
}
});
const res = await Promise.all( shotSelectionList.map(async (shot) => {
// 调用应用角色到分镜接口(不等待完成)
return applyRoleToShots({
project_id: projectId,
shot_id: shot.id, // 单个分镜ID
character_replacements: characterReplacements,
wait_for_completion: false, // 不等待完成,异步处理
character_draft: JSON.stringify(newDraftRoleList)
})
}))
console.log(`开始为 ${shotSelectionList.length} 个分镜替换角色`);
SaveEditUseCase.setVideoTasks([
...SaveEditUseCase.videoTasks,
...res.map(item=>{
return {
task_id: item.data.task_id,
video_ids: [item.data.shot_id]
}
})
])
console.log([
...SaveEditUseCase.videoTasks,
...res.map(item=>{
return {
task_id: item.data.task_id,
video_ids: [item.data.shot_id]
}
})
]);
// 延迟重置替换状态,给用户一些反馈时间
setTimeout(() => {

View File

@ -149,7 +149,6 @@ export class VideoSegmentEditUseCase {
const response = await updateShotPrompt({
project_id,
shot_id,
shot_id,
shot_descriptions,
});