修复同步类型

This commit is contained in:
海龙 2025-08-14 23:01:03 +08:00
parent 52339e2076
commit cafaf5102a
5 changed files with 43 additions and 29 deletions

View File

@ -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;
}[];
}>;
/** 总数量 */

View File

@ -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]);
/**
*

View File

@ -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,

View File

@ -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[];
}

View File

@ -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