From e5f6684ee27898d3c4de0e825fb78508e0e3be06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E9=BE=99?= Date: Mon, 18 Aug 2025 19:01:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=81=9C=E6=AD=A2=E8=BD=AE=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/service/Interaction/ShotService.ts | 9 +++++++-- app/service/usecase/ShotEditUsecase.ts | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) 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) {