修复问题

This commit is contained in:
海龙 2025-08-13 20:39:02 +08:00
parent 9fbdcafcff
commit 2ab25bc72c
3 changed files with 119 additions and 27 deletions

View File

@ -281,7 +281,7 @@ export const regenerateRole = async (request: {
/**
*
* @param request -
* @returns Promise<ApiResponse<应用结果>>
* @returns Promise<ApiResponse<任务状态>>
*/
export const applyRoleToShots = async (request: {
/** 项目ID */
@ -295,17 +295,22 @@ export const applyRoleToShots = async (request: {
/** 数据缓存 */
character_draft: string;
}): Promise<ApiResponse<{
/** 应用成功的分镜数量 */
success_count: number;
/** 应用失败的分镜数量 */
failed_count: number;
/** 应用结果详情 */
results: Array<{
shot_id: string;
success: boolean;
message?: string;
}>;
/** 任务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);
};
@ -538,7 +543,7 @@ export const getShotData = async (request: {
/**
*
* @param request -
* @returns Promise<ApiResponse<重新生成的分镜>>
* @returns Promise<ApiResponse<任务状态>>
*/
export const regenerateShot = async (request: {
/** 项目ID */
@ -551,8 +556,25 @@ export const regenerateShot = async (request: {
// roleReplaceParams?: { oldId: string; newId: string }[];
// /** 场景ID替换参数格式为{oldId:string,newId:string}[] */
// sceneReplaceParams?: { oldId: string; newId: string }[];
}): Promise<ApiResponse<VideoSegmentEntity>> => {
return post<ApiResponse<any>>("/movie/regenerate_shot_video", request);
}): Promise<ApiResponse<{
/** 任务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 */
project_id: string;
/** 分镜ID */
shot_id: string;
video_id: string;
/** 镜头描述 */
shot_descriptions: task_item;
}): Promise<ApiResponse<any>> => {
@ -1077,4 +1099,64 @@ export const checkShotVideoStatus = async (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);
};

View File

@ -28,9 +28,7 @@ export interface UseShotService {
/** 获取视频片段列表 */
getVideoSegmentList: (projectId: string) => Promise<void>;
/** 重新生成视频片段 */
regenerateVideoSegment: () => // roleReplaceParams?: { oldId: string; newId: string }[],
// sceneReplaceParams?: { oldId: string; newId: string }[]
Promise<VideoSegmentEntity>;
regenerateVideoSegment: () => Promise<VideoSegmentEntity>;
/** AI优化视频内容 */
optimizeVideoContent: (
shotId: string,
@ -81,7 +79,7 @@ export const useShotService = (): UseShotService => {
const [vidoEditUseCase] = useState<VideoSegmentEditUseCase>(
new VideoSegmentEditUseCase()
);
const [generateTaskIds, setGenerateTaskIds] = useState<Set<string>>(new Set());
/**
*
* @param projectId ID
@ -174,22 +172,33 @@ export const useShotService = (): UseShotService => {
try {
setLoading(true);
const regeneratedSegment = await vidoEditUseCase.regenerateVideoSegment(
// 调用API重新生成视频片段返回任务状态信息
const taskResult = await vidoEditUseCase.regenerateVideoSegment(
projectId,
selectedSegment!.lens,
selectedSegment!.id
);
// 如果重新生成的是现有片段,更新列表中的对应项
// 保存任务ID用于后续状态查询
setGenerateTaskIds(prev => prev.add(taskResult.task_id));
// 如果重新生成的是现有片段,更新其状态为处理中 (0: 视频加载中)
if (selectedSegment) {
setVideoSegments((prev) =>
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) {
console.error("重新生成视频片段失败:", error);
throw error;

View File

@ -148,7 +148,7 @@ export class VideoSegmentEditUseCase {
const response = await updateShotPrompt({
project_id,
shot_id,
video_id:shot_id,
shot_descriptions,
});
@ -170,7 +170,7 @@ export class VideoSegmentEditUseCase {
* @param project_id ID
* @param shot_Lens
* @param shot_id ID
* @returns Promise<VideoSegmentEntity>
* @returns Promise<任务状态信息>
*/
async regenerateVideoSegment(
project_id: string,
@ -178,7 +178,7 @@ export class VideoSegmentEditUseCase {
shot_id?: string,
// roleReplaceParams?: { oldId: string; newId: string }[],
// sceneReplaceParams?: { oldId: string; newId: string }[]
): Promise<VideoSegmentEntity> {
){
try {
this.loading = true;
const shot_descriptions = VideoSegmentEntityAdapter.lensTypeToTaskItem(shot_Lens);
@ -199,6 +199,7 @@ export class VideoSegmentEditUseCase {
throw new Error(response.message || "重新生成视频片段失败");
}
// 现在返回的是任务状态信息包含task_id、status等
return response.data;
} catch (error) {
console.error("重新生成视频片段失败:", error);