forked from 77media/video-flow
修复问题
This commit is contained in:
parent
9fbdcafcff
commit
2ab25bc72c
@ -281,7 +281,7 @@ export const regenerateRole = async (request: {
|
|||||||
/**
|
/**
|
||||||
* 应用角色到分镜
|
* 应用角色到分镜
|
||||||
* @param request - 应用角色请求参数
|
* @param request - 应用角色请求参数
|
||||||
* @returns Promise<ApiResponse<应用结果>>
|
* @returns Promise<ApiResponse<任务状态>>
|
||||||
*/
|
*/
|
||||||
export const applyRoleToShots = async (request: {
|
export const applyRoleToShots = async (request: {
|
||||||
/** 项目ID */
|
/** 项目ID */
|
||||||
@ -295,17 +295,22 @@ export const applyRoleToShots = async (request: {
|
|||||||
/** 数据缓存 */
|
/** 数据缓存 */
|
||||||
character_draft: string;
|
character_draft: string;
|
||||||
}): Promise<ApiResponse<{
|
}): Promise<ApiResponse<{
|
||||||
/** 应用成功的分镜数量 */
|
/** 任务ID */
|
||||||
success_count: number;
|
task_id: string;
|
||||||
/** 应用失败的分镜数量 */
|
/** 项目ID */
|
||||||
failed_count: number;
|
project_id: string;
|
||||||
|
/** 分镜ID */
|
||||||
/** 应用结果详情 */
|
shot_id: string;
|
||||||
results: Array<{
|
/** 任务状态 */
|
||||||
shot_id: string;
|
status: string;
|
||||||
success: boolean;
|
/** 状态描述 */
|
||||||
message?: string;
|
message: string;
|
||||||
}>;
|
/** 视频URL列表(仅当wait_for_completion=true且完成时) */
|
||||||
|
urls?: string[];
|
||||||
|
/** 是否完成 */
|
||||||
|
finished: boolean;
|
||||||
|
/** 耗时(秒,仅当wait_for_completion=true时) */
|
||||||
|
elapsed_time?: number;
|
||||||
}>> => {
|
}>> => {
|
||||||
return post("/movie/regenerate_shot_video", request);
|
return post("/movie/regenerate_shot_video", request);
|
||||||
};
|
};
|
||||||
@ -538,7 +543,7 @@ export const getShotData = async (request: {
|
|||||||
/**
|
/**
|
||||||
* 重新生成分镜
|
* 重新生成分镜
|
||||||
* @param request - 重新生成分镜请求参数
|
* @param request - 重新生成分镜请求参数
|
||||||
* @returns Promise<ApiResponse<重新生成的分镜>>
|
* @returns Promise<ApiResponse<任务状态>>
|
||||||
*/
|
*/
|
||||||
export const regenerateShot = async (request: {
|
export const regenerateShot = async (request: {
|
||||||
/** 项目ID */
|
/** 项目ID */
|
||||||
@ -551,8 +556,25 @@ export const regenerateShot = async (request: {
|
|||||||
// roleReplaceParams?: { oldId: string; newId: string }[];
|
// roleReplaceParams?: { oldId: string; newId: string }[];
|
||||||
// /** 场景ID替换参数,格式为{oldId:string,newId:string}[] */
|
// /** 场景ID替换参数,格式为{oldId:string,newId:string}[] */
|
||||||
// sceneReplaceParams?: { oldId: string; newId: string }[];
|
// sceneReplaceParams?: { oldId: string; newId: string }[];
|
||||||
}): Promise<ApiResponse<VideoSegmentEntity>> => {
|
}): Promise<ApiResponse<{
|
||||||
return post<ApiResponse<any>>("/movie/regenerate_shot_video", request);
|
/** 任务ID */
|
||||||
|
task_id: string;
|
||||||
|
/** 项目ID */
|
||||||
|
project_id: string;
|
||||||
|
/** 分镜ID */
|
||||||
|
shot_id: string;
|
||||||
|
/** 任务状态 */
|
||||||
|
status: string;
|
||||||
|
/** 状态描述 */
|
||||||
|
message: string;
|
||||||
|
/** 视频URL列表(仅当wait_for_completion=true且完成时) */
|
||||||
|
urls?: string[];
|
||||||
|
/** 是否完成 */
|
||||||
|
finished: boolean;
|
||||||
|
/** 耗时(秒,仅当wait_for_completion=true时) */
|
||||||
|
elapsed_time?: number;
|
||||||
|
}>> => {
|
||||||
|
return post("/movie/regenerate_shot_video", request);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -843,7 +865,7 @@ export const updateShotPrompt = async (request: {
|
|||||||
/** 项目ID */
|
/** 项目ID */
|
||||||
project_id: string;
|
project_id: string;
|
||||||
/** 分镜ID */
|
/** 分镜ID */
|
||||||
shot_id: string;
|
video_id: string;
|
||||||
/** 镜头描述 */
|
/** 镜头描述 */
|
||||||
shot_descriptions: task_item;
|
shot_descriptions: task_item;
|
||||||
}): Promise<ApiResponse<any>> => {
|
}): Promise<ApiResponse<any>> => {
|
||||||
@ -1077,4 +1099,64 @@ export const checkShotVideoStatus = async (request: {
|
|||||||
return post<ApiResponse<any>>("/check_shot_video_status", request);
|
return post<ApiResponse<any>>("/check_shot_video_status", request);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 智能检测修改类型并进行相应的修改操作
|
||||||
|
* @description 支持角色修改和分镜修改的自动判断与批量处理
|
||||||
|
* @param request - 请求参数
|
||||||
|
* @returns Promise<ApiResponse<智能修改结果>>
|
||||||
|
*/
|
||||||
|
export const modifyCharacterOrScene = async (request: {
|
||||||
|
/** 项目ID */
|
||||||
|
project_id: string;
|
||||||
|
/** 角色ID(可能为null) */
|
||||||
|
character_id?: string | null;
|
||||||
|
/** 视频任务关联列表 */
|
||||||
|
video_tasks: Array<{
|
||||||
|
/** 生成视频的任务ID */
|
||||||
|
task_id: string;
|
||||||
|
/** 该任务对应的video_id列表 */
|
||||||
|
video_ids: string[];
|
||||||
|
}>;
|
||||||
|
}): Promise<ApiResponse<{
|
||||||
|
/** 项目ID */
|
||||||
|
project_id: string;
|
||||||
|
/** 自动检测到的修改类型("character" 或 "scene") */
|
||||||
|
modify_type: "character" | "scene";
|
||||||
|
/** 传入的视频任务列表 */
|
||||||
|
video_tasks: Array<{
|
||||||
|
task_id: string;
|
||||||
|
video_ids: string[];
|
||||||
|
}>;
|
||||||
|
/** 处理结果描述 */
|
||||||
|
message: string;
|
||||||
|
/** 详细处理信息 */
|
||||||
|
details: Record<string, any>;
|
||||||
|
/** 警告信息(如有) */
|
||||||
|
warning: string | null;
|
||||||
|
/** 启动的视频检测任务列表 */
|
||||||
|
video_check_tasks: Array<{
|
||||||
|
task_id: string;
|
||||||
|
video_ids: string[];
|
||||||
|
}>;
|
||||||
|
/** 启动的视频检测任务数量 */
|
||||||
|
video_check_started: number;
|
||||||
|
}>> => {
|
||||||
|
return post<ApiResponse<{
|
||||||
|
project_id: string;
|
||||||
|
modify_type: "character" | "scene";
|
||||||
|
video_tasks: Array<{
|
||||||
|
task_id: string;
|
||||||
|
video_ids: string[];
|
||||||
|
}>;
|
||||||
|
message: string;
|
||||||
|
details: Record<string, any>;
|
||||||
|
warning: string | null;
|
||||||
|
video_check_tasks: Array<{
|
||||||
|
task_id: string;
|
||||||
|
video_ids: string[];
|
||||||
|
}>;
|
||||||
|
video_check_started: number;
|
||||||
|
}>>("/character/modify_character_or_scene", request);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -28,9 +28,7 @@ export interface UseShotService {
|
|||||||
/** 获取视频片段列表 */
|
/** 获取视频片段列表 */
|
||||||
getVideoSegmentList: (projectId: string) => Promise<void>;
|
getVideoSegmentList: (projectId: string) => Promise<void>;
|
||||||
/** 重新生成视频片段 */
|
/** 重新生成视频片段 */
|
||||||
regenerateVideoSegment: () => // roleReplaceParams?: { oldId: string; newId: string }[],
|
regenerateVideoSegment: () => Promise<VideoSegmentEntity>;
|
||||||
// sceneReplaceParams?: { oldId: string; newId: string }[]
|
|
||||||
Promise<VideoSegmentEntity>;
|
|
||||||
/** AI优化视频内容 */
|
/** AI优化视频内容 */
|
||||||
optimizeVideoContent: (
|
optimizeVideoContent: (
|
||||||
shotId: string,
|
shotId: string,
|
||||||
@ -81,7 +79,7 @@ export const useShotService = (): UseShotService => {
|
|||||||
const [vidoEditUseCase] = useState<VideoSegmentEditUseCase>(
|
const [vidoEditUseCase] = useState<VideoSegmentEditUseCase>(
|
||||||
new VideoSegmentEditUseCase()
|
new VideoSegmentEditUseCase()
|
||||||
);
|
);
|
||||||
|
const [generateTaskIds, setGenerateTaskIds] = useState<Set<string>>(new Set());
|
||||||
/**
|
/**
|
||||||
* 获取视频片段列表
|
* 获取视频片段列表
|
||||||
* @param projectId 项目ID
|
* @param projectId 项目ID
|
||||||
@ -174,22 +172,33 @@ export const useShotService = (): UseShotService => {
|
|||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
|
||||||
const regeneratedSegment = await vidoEditUseCase.regenerateVideoSegment(
|
// 调用API重新生成视频片段,返回任务状态信息
|
||||||
|
const taskResult = await vidoEditUseCase.regenerateVideoSegment(
|
||||||
projectId,
|
projectId,
|
||||||
selectedSegment!.lens,
|
selectedSegment!.lens,
|
||||||
selectedSegment!.id
|
selectedSegment!.id
|
||||||
);
|
);
|
||||||
|
|
||||||
// 如果重新生成的是现有片段,更新列表中的对应项
|
// 保存任务ID用于后续状态查询
|
||||||
|
setGenerateTaskIds(prev => prev.add(taskResult.task_id));
|
||||||
|
|
||||||
|
// 如果重新生成的是现有片段,更新其状态为处理中 (0: 视频加载中)
|
||||||
if (selectedSegment) {
|
if (selectedSegment) {
|
||||||
setVideoSegments((prev) =>
|
setVideoSegments((prev) =>
|
||||||
prev.map((segment) =>
|
prev.map((segment) =>
|
||||||
segment.id === selectedSegment.id ? regeneratedSegment : segment
|
segment.id === selectedSegment.id
|
||||||
|
? {
|
||||||
|
...segment,
|
||||||
|
status: 0, // 设置为视频加载中状态
|
||||||
|
loadingProgress: 0 // 重置加载进度
|
||||||
|
}
|
||||||
|
: segment
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return regeneratedSegment;
|
// 返回当前选中的片段,因为现在API返回的是任务状态而不是完整的片段
|
||||||
|
return selectedSegment!;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("重新生成视频片段失败:", error);
|
console.error("重新生成视频片段失败:", error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
@ -148,7 +148,7 @@ export class VideoSegmentEditUseCase {
|
|||||||
|
|
||||||
const response = await updateShotPrompt({
|
const response = await updateShotPrompt({
|
||||||
project_id,
|
project_id,
|
||||||
shot_id,
|
video_id:shot_id,
|
||||||
shot_descriptions,
|
shot_descriptions,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ export class VideoSegmentEditUseCase {
|
|||||||
* @param project_id 项目ID
|
* @param project_id 项目ID
|
||||||
* @param shot_Lens 镜头描述数据
|
* @param shot_Lens 镜头描述数据
|
||||||
* @param shot_id 视频片段ID(可选,如果重新生成现有片段)
|
* @param shot_id 视频片段ID(可选,如果重新生成现有片段)
|
||||||
* @returns Promise<VideoSegmentEntity> 重新生成的视频片段
|
* @returns Promise<任务状态信息> 重新生成任务的状态信息
|
||||||
*/
|
*/
|
||||||
async regenerateVideoSegment(
|
async regenerateVideoSegment(
|
||||||
project_id: string,
|
project_id: string,
|
||||||
@ -178,7 +178,7 @@ export class VideoSegmentEditUseCase {
|
|||||||
shot_id?: string,
|
shot_id?: string,
|
||||||
// roleReplaceParams?: { oldId: string; newId: string }[],
|
// roleReplaceParams?: { oldId: string; newId: string }[],
|
||||||
// sceneReplaceParams?: { oldId: string; newId: string }[]
|
// sceneReplaceParams?: { oldId: string; newId: string }[]
|
||||||
): Promise<VideoSegmentEntity> {
|
){
|
||||||
try {
|
try {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
const shot_descriptions = VideoSegmentEntityAdapter.lensTypeToTaskItem(shot_Lens);
|
const shot_descriptions = VideoSegmentEntityAdapter.lensTypeToTaskItem(shot_Lens);
|
||||||
@ -199,6 +199,7 @@ export class VideoSegmentEditUseCase {
|
|||||||
throw new Error(response.message || "重新生成视频片段失败");
|
throw new Error(response.message || "重新生成视频片段失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 现在返回的是任务状态信息,包含task_id、status等
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("重新生成视频片段失败:", error);
|
console.error("重新生成视频片段失败:", error);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user