diff --git a/app/service/Interaction/ShotService.ts b/app/service/Interaction/ShotService.ts index c3682ba..1b5f0b2 100644 --- a/app/service/Interaction/ShotService.ts +++ b/app/service/Interaction/ShotService.ts @@ -112,7 +112,12 @@ export const useShotService = (): UseShotService => { // 定义定时任务,每5秒执行一次 const newIntervalId = setInterval(async () => { try { - const segments = await vidoEditUseCase.getVideoSegmentList(projectId); + const segments = await vidoEditUseCase.getVideoSegmentList(projectId,()=>{ + if (intervalId) { + clearInterval(intervalId); + setIntervalId(null); + } + }); setVideoSegments((prevSegments) => { const existingSegmentsMap = new Map( @@ -143,7 +148,7 @@ export const useShotService = (): UseShotService => { } catch (error) { console.error("定时获取视频片段列表失败:", error); } - }, 5000); + }, 30000); setIntervalId(newIntervalId); }; diff --git a/app/service/usecase/ShotEditUsecase.ts b/app/service/usecase/ShotEditUsecase.ts index 5f2886f..f5e41da 100644 --- a/app/service/usecase/ShotEditUsecase.ts +++ b/app/service/usecase/ShotEditUsecase.ts @@ -24,7 +24,7 @@ export class VideoSegmentEditUseCase { * @param projectId 项目ID * @returns Promise 视频片段列表 */ - async getVideoSegmentList(projectId: string): Promise { + async getVideoSegmentList(projectId: string,callback?:()=>void): Promise { try { this.loading = true; @@ -33,7 +33,10 @@ export class VideoSegmentEditUseCase { if (!response.successful) { throw new Error(response.message || "获取视频片段列表失败"); } + if(response.data.task_status=="COMPLETED"){ + callback?.(); + } const Segments = VideoSegmentEntityAdapter.toVideoSegmentEntity(response.data) || []; const detail = await detailScriptEpisodeNew({ project_id: projectId }); if (!detail.successful || !detail.data) {