From cafaf5102a797e26339c0994ecce303180381540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E9=BE=99?= Date: Thu, 14 Aug 2025 23:01:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E6=AD=A5=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/video_flow.ts | 8 +++- app/service/Interaction/RoleShotService.ts | 4 +- app/service/adapter/oldErrAdapter.ts | 46 ++++++++++++---------- app/service/domain/Entities.ts | 8 +++- app/service/usecase/ShotEditUsecase.ts | 6 +-- 5 files changed, 43 insertions(+), 29 deletions(-) diff --git a/api/video_flow.ts b/api/video_flow.ts index 85ec98b..864b443 100644 --- a/api/video_flow.ts +++ b/api/video_flow.ts @@ -985,7 +985,7 @@ export const batchUpdateVideoSegments = async (request: { /** 新的视频地址列表 */ video_urls: string[]; /** 新的状态 0:视频加载中 1:任务已完成 2:任务失败 */ - status: 0 | 1 | 2; + status: number; /** 优化后的描述文本 */ optimized_description?: string; /** 关键词列表 */ @@ -1026,7 +1026,11 @@ export const getCharacterShots = async (request: { /** 视频ID */ video_id: string; /** 视频URL列表 */ - video_urls: string[]; + video_urls: { + video_url: string; + video_id: string; + video_status: number|null; + }[]; }>; /** 总数量 */ diff --git a/app/service/Interaction/RoleShotService.ts b/app/service/Interaction/RoleShotService.ts index 37072c2..3c47515 100644 --- a/app/service/Interaction/RoleShotService.ts +++ b/app/service/Interaction/RoleShotService.ts @@ -97,7 +97,7 @@ export const useRoleShotServiceHook = (projectId: string,selectRole?:RoleEntity, id: scene.video_id, name: `视频片段_${scene.video_id}`, sketchUrl: "", - videoUrl: scene.video_urls, // 保持为string[]类型 + videoUrl: scene.video_urls,// 保持为string[]类型 status:scene.video_urls.length>0?1:0, // 默认为已完成状态 lens: [], updatedAt: Date.now(), @@ -223,7 +223,7 @@ export const useRoleShotServiceHook = (projectId: string,selectRole?:RoleEntity, setIsReplacing(false); throw error; } - }, [selectedRole, shotSelectionList, projectId, isReplacing]); + }, [selectedRole, isReplacing, draftRoleList, shotSelectionList, projectId]); /** * 清空选择列表 diff --git a/app/service/adapter/oldErrAdapter.ts b/app/service/adapter/oldErrAdapter.ts index b2c4630..0753af9 100644 --- a/app/service/adapter/oldErrAdapter.ts +++ b/app/service/adapter/oldErrAdapter.ts @@ -63,6 +63,10 @@ export class VideoSegmentEntityAdapter { videos: Array<{ /** 视频地址 */ video_url: string; + /** 视频ID */ + video_id: string; + /**视频片段状态 0:视频加载中 1:任务已完成 2:任务失败 */ + video_status: number|null; }>; }> = []; @@ -131,23 +135,21 @@ export class VideoSegmentEntityAdapter { } // 提取视频URL列表 - const videoUrls: string[] = []; - if (result.videos && result.videos.length > 0) { - videoUrls.push(...result.videos.map(video => video.video_url)); - } + // const videoUrls: { + // video_url: string; + // video_id: string; + // video_status: number|null; + // }[] = result.videos; + // if (result.videos && result.videos.length > 0) { + // videoUrls.push(...result.videos.map(video => ({ + // video_url: video.video_url, + // video_id: video.video_id, + // video_status: video.video_status||1 + // }))); + // } // 根据task_status和videoUrls内容确定状态 - let status: 0 | 1 | 2 = 1; // 默认为已完成状态 - if (data.task_status === "INIT" || data.task_status === "IN_PROGRESS") { - // 进行中:videoUrls[0]有内容为已完成,否则为处理中 - status = videoUrls[0] ? 1 : 0; - } else if (data.task_status === "COMPLETED") { - // 已完成:videoUrls[0]有内容为已完成,否则为失败 - status = videoUrls[0] ? 1 : 2; - } else if (data.task_status === "FAILED") { - // 失败:全部为失败 - status = 2; - } + let status = result.videos[0]?.video_status||1 // 创建VideoSegmentEntity const entity: VideoSegmentEntity = { @@ -156,7 +158,7 @@ export class VideoSegmentEntityAdapter { loadingProgress: status === 1 ? 100 : status === 0 ? 50 : 0, // 已完成100%,进行中50%,失败0% name: `视频片段_${index}`, // 生成临时名称,包含索引 sketchUrl: "", // 后端数据中没有sketchUrl,设为空字符串 - videoUrl: videoUrls, + videoUrl: result.videos, status: status, lens: lens }; @@ -186,7 +188,7 @@ export class VideoSegmentEntityAdapter { shot_8: string; shot_9: string; shot_10: string; - videos: Array<{ video_url: string }>; + videos: Array<{ video_url: string; video_id: string; video_status: number|null }>; }> = []; // 遍历每个实体,转换为task_result项 @@ -225,9 +227,13 @@ export class VideoSegmentEntityAdapter { } // 构建videos数组 - const videos = entity.videoUrl.map(url => ({ - video_url: url - })); + const videos = entity.videoUrl.map(url => { + return { + video_url: url.video_url, + video_id: url.video_id, + video_status: url.video_status + } + }); taskResults.push({ narrative_goal: narrative_goal, diff --git a/app/service/domain/Entities.ts b/app/service/domain/Entities.ts index c6afc63..d008fc9 100644 --- a/app/service/domain/Entities.ts +++ b/app/service/domain/Entities.ts @@ -67,9 +67,13 @@ export interface VideoSegmentEntity extends BaseEntity { /**视频片段草图Url */ sketchUrl: string; /**视频片段视频Url */ - videoUrl: string[]; + videoUrl: { + video_url: string; + video_id: string; + video_status: number|null; + }[]; /**视频片段状态 0:视频加载中 1:任务已完成 2:任务失败 */ - status: 0 | 1 | 2; + status: number; /**镜头项 */ lens: LensType[]; } diff --git a/app/service/usecase/ShotEditUsecase.ts b/app/service/usecase/ShotEditUsecase.ts index 7ed9144..5f2886f 100644 --- a/app/service/usecase/ShotEditUsecase.ts +++ b/app/service/usecase/ShotEditUsecase.ts @@ -94,8 +94,8 @@ export class VideoSegmentEditUseCase { segments.forEach(segment => { if (segment.videoUrl && Array.isArray(segment.videoUrl)) { // 查找匹配的视频项 - const matchedVideo = segment.videoUrl.find(url => urlToVideoMap.has(url)); - const videoItem = matchedVideo ? urlToVideoMap.get(matchedVideo) : null; + const matchedVideo = segment.videoUrl.find(url => urlToVideoMap.has(url.video_url)); + const videoItem = matchedVideo ? urlToVideoMap.get(matchedVideo.video_url) : null; if (videoItem) { // 创建新的实体实例,设置正确的id @@ -275,7 +275,7 @@ export class VideoSegmentEditUseCase { // 准备更新数据 const updateData = otherSegments.map(segment => ({ shot_id: segment.id, - video_urls: segment.videoUrl || [], + video_urls: segment.videoUrl.map(url=>url.video_url) || [], status: segment.status, optimized_description: optimizedDescription, keywords: keywords