diff --git a/api/video_flow.ts b/api/video_flow.ts index 1a43125..6937ff3 100644 --- a/api/video_flow.ts +++ b/api/video_flow.ts @@ -281,7 +281,7 @@ export const regenerateRole = async (request: { /** * 应用角色到分镜 * @param request - 应用角色请求参数 - * @returns Promise> + * @returns Promise> */ export const applyRoleToShots = async (request: { /** 项目ID */ @@ -295,17 +295,22 @@ export const applyRoleToShots = async (request: { /** 数据缓存 */ character_draft: string; }): Promise; + /** 任务ID */ + task_id: string; + /** 项目ID */ + project_id: string; + /** 分镜ID */ + shot_id: string; + /** 任务状态 */ + status: string; + /** 状态描述 */ + message: string; + /** 视频URL列表(仅当wait_for_completion=true且完成时) */ + urls?: string[]; + /** 是否完成 */ + finished: boolean; + /** 耗时(秒,仅当wait_for_completion=true时) */ + elapsed_time?: number; }>> => { return post("/movie/regenerate_shot_video", request); }; @@ -538,7 +543,7 @@ export const getShotData = async (request: { /** * 重新生成分镜 * @param request - 重新生成分镜请求参数 - * @returns Promise> + * @returns Promise> */ export const regenerateShot = async (request: { /** 项目ID */ @@ -551,8 +556,25 @@ export const regenerateShot = async (request: { // roleReplaceParams?: { oldId: string; newId: string }[]; // /** 场景ID替换参数,格式为{oldId:string,newId:string}[] */ // sceneReplaceParams?: { oldId: string; newId: string }[]; -}): Promise> => { - return post>("/movie/regenerate_shot_video", request); +}): Promise> => { + return post("/movie/regenerate_shot_video", request); }; @@ -843,7 +865,7 @@ export const updateShotPrompt = async (request: { /** 项目ID */ project_id: string; /** 分镜ID */ - shot_id: string; + video_id: string; /** 镜头描述 */ shot_descriptions: task_item; }): Promise> => { @@ -1077,4 +1099,64 @@ export const checkShotVideoStatus = async (request: { return post>("/check_shot_video_status", request); }; +/** + * 智能检测修改类型并进行相应的修改操作 + * @description 支持角色修改和分镜修改的自动判断与批量处理 + * @param request - 请求参数 + * @returns Promise> + */ +export const modifyCharacterOrScene = async (request: { + /** 项目ID */ + project_id: string; + /** 角色ID(可能为null) */ + character_id?: string | null; + /** 视频任务关联列表 */ + video_tasks: Array<{ + /** 生成视频的任务ID */ + task_id: string; + /** 该任务对应的video_id列表 */ + video_ids: string[]; + }>; +}): Promise; + /** 处理结果描述 */ + message: string; + /** 详细处理信息 */ + details: Record; + /** 警告信息(如有) */ + warning: string | null; + /** 启动的视频检测任务列表 */ + video_check_tasks: Array<{ + task_id: string; + video_ids: string[]; + }>; + /** 启动的视频检测任务数量 */ + video_check_started: number; +}>> => { + return post; + message: string; + details: Record; + warning: string | null; + video_check_tasks: Array<{ + task_id: string; + video_ids: string[]; + }>; + video_check_started: number; + }>>("/character/modify_character_or_scene", request); +}; + diff --git a/app/service/Interaction/ShotService.ts b/app/service/Interaction/ShotService.ts index 90f7439..34b375c 100644 --- a/app/service/Interaction/ShotService.ts +++ b/app/service/Interaction/ShotService.ts @@ -28,9 +28,7 @@ export interface UseShotService { /** 获取视频片段列表 */ getVideoSegmentList: (projectId: string) => Promise; /** 重新生成视频片段 */ - regenerateVideoSegment: () => // roleReplaceParams?: { oldId: string; newId: string }[], - // sceneReplaceParams?: { oldId: string; newId: string }[] - Promise; + regenerateVideoSegment: () => Promise; /** AI优化视频内容 */ optimizeVideoContent: ( shotId: string, @@ -81,7 +79,7 @@ export const useShotService = (): UseShotService => { const [vidoEditUseCase] = useState( new VideoSegmentEditUseCase() ); - + const [generateTaskIds, setGenerateTaskIds] = useState>(new Set()); /** * 获取视频片段列表 * @param projectId 项目ID @@ -174,22 +172,33 @@ export const useShotService = (): UseShotService => { try { setLoading(true); - const regeneratedSegment = await vidoEditUseCase.regenerateVideoSegment( + // 调用API重新生成视频片段,返回任务状态信息 + const taskResult = await vidoEditUseCase.regenerateVideoSegment( projectId, selectedSegment!.lens, selectedSegment!.id ); - // 如果重新生成的是现有片段,更新列表中的对应项 + // 保存任务ID用于后续状态查询 + setGenerateTaskIds(prev => prev.add(taskResult.task_id)); + + // 如果重新生成的是现有片段,更新其状态为处理中 (0: 视频加载中) if (selectedSegment) { setVideoSegments((prev) => prev.map((segment) => - segment.id === selectedSegment.id ? regeneratedSegment : segment + segment.id === selectedSegment.id + ? { + ...segment, + status: 0, // 设置为视频加载中状态 + loadingProgress: 0 // 重置加载进度 + } + : segment ) ); } - return regeneratedSegment; + // 返回当前选中的片段,因为现在API返回的是任务状态而不是完整的片段 + return selectedSegment!; } catch (error) { console.error("重新生成视频片段失败:", error); throw error; diff --git a/app/service/usecase/ShotEditUsecase.ts b/app/service/usecase/ShotEditUsecase.ts index fcd125c..29e5066 100644 --- a/app/service/usecase/ShotEditUsecase.ts +++ b/app/service/usecase/ShotEditUsecase.ts @@ -148,7 +148,7 @@ export class VideoSegmentEditUseCase { const response = await updateShotPrompt({ project_id, - shot_id, + video_id:shot_id, shot_descriptions, }); @@ -170,7 +170,7 @@ export class VideoSegmentEditUseCase { * @param project_id 项目ID * @param shot_Lens 镜头描述数据 * @param shot_id 视频片段ID(可选,如果重新生成现有片段) - * @returns Promise 重新生成的视频片段 + * @returns Promise<任务状态信息> 重新生成任务的状态信息 */ async regenerateVideoSegment( project_id: string, @@ -178,7 +178,7 @@ export class VideoSegmentEditUseCase { shot_id?: string, // roleReplaceParams?: { oldId: string; newId: string }[], // sceneReplaceParams?: { oldId: string; newId: string }[] - ): Promise { + ){ try { this.loading = true; const shot_descriptions = VideoSegmentEntityAdapter.lensTypeToTaskItem(shot_Lens); @@ -199,6 +199,7 @@ export class VideoSegmentEditUseCase { throw new Error(response.message || "重新生成视频片段失败"); } + // 现在返回的是任务状态信息,包含task_id、status等 return response.data; } catch (error) { console.error("重新生成视频片段失败:", error);