停止轮询

This commit is contained in:
海龙 2025-08-18 19:01:42 +08:00
parent 4904c29ce6
commit e5f6684ee2
2 changed files with 11 additions and 3 deletions

View File

@ -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);
};

View File

@ -24,7 +24,7 @@ export class VideoSegmentEditUseCase {
* @param projectId ID
* @returns Promise<VideoSegmentEntity[]>
*/
async getVideoSegmentList(projectId: string): Promise<VideoSegmentEntity[]> {
async getVideoSegmentList(projectId: string,callback?:()=>void): Promise<VideoSegmentEntity[]> {
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) {