forked from 77media/video-flow
停止轮询
This commit is contained in:
parent
4904c29ce6
commit
e5f6684ee2
@ -112,7 +112,12 @@ export const useShotService = (): UseShotService => {
|
|||||||
// 定义定时任务,每5秒执行一次
|
// 定义定时任务,每5秒执行一次
|
||||||
const newIntervalId = setInterval(async () => {
|
const newIntervalId = setInterval(async () => {
|
||||||
try {
|
try {
|
||||||
const segments = await vidoEditUseCase.getVideoSegmentList(projectId);
|
const segments = await vidoEditUseCase.getVideoSegmentList(projectId,()=>{
|
||||||
|
if (intervalId) {
|
||||||
|
clearInterval(intervalId);
|
||||||
|
setIntervalId(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setVideoSegments((prevSegments) => {
|
setVideoSegments((prevSegments) => {
|
||||||
const existingSegmentsMap = new Map(
|
const existingSegmentsMap = new Map(
|
||||||
@ -143,7 +148,7 @@ export const useShotService = (): UseShotService => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("定时获取视频片段列表失败:", error);
|
console.error("定时获取视频片段列表失败:", error);
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, 30000);
|
||||||
|
|
||||||
setIntervalId(newIntervalId);
|
setIntervalId(newIntervalId);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -24,7 +24,7 @@ export class VideoSegmentEditUseCase {
|
|||||||
* @param projectId 项目ID
|
* @param projectId 项目ID
|
||||||
* @returns Promise<VideoSegmentEntity[]> 视频片段列表
|
* @returns Promise<VideoSegmentEntity[]> 视频片段列表
|
||||||
*/
|
*/
|
||||||
async getVideoSegmentList(projectId: string): Promise<VideoSegmentEntity[]> {
|
async getVideoSegmentList(projectId: string,callback?:()=>void): Promise<VideoSegmentEntity[]> {
|
||||||
try {
|
try {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
|
|
||||||
@ -33,7 +33,10 @@ export class VideoSegmentEditUseCase {
|
|||||||
if (!response.successful) {
|
if (!response.successful) {
|
||||||
throw new Error(response.message || "获取视频片段列表失败");
|
throw new Error(response.message || "获取视频片段列表失败");
|
||||||
}
|
}
|
||||||
|
if(response.data.task_status=="COMPLETED"){
|
||||||
|
callback?.();
|
||||||
|
|
||||||
|
}
|
||||||
const Segments = VideoSegmentEntityAdapter.toVideoSegmentEntity(response.data) || [];
|
const Segments = VideoSegmentEntityAdapter.toVideoSegmentEntity(response.data) || [];
|
||||||
const detail = await detailScriptEpisodeNew({ project_id: projectId });
|
const detail = await detailScriptEpisodeNew({ project_id: projectId });
|
||||||
if (!detail.successful || !detail.data) {
|
if (!detail.successful || !detail.data) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user