forked from 77media/video-flow
一堆改英文
This commit is contained in:
parent
0fa84b466f
commit
a5ea76a28e
@ -251,7 +251,7 @@ export const stream = async <T>({
|
|||||||
onComplete?.();
|
onComplete?.();
|
||||||
return response;
|
return response;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
handleRequestError(error, '流式请求失败');
|
handleRequestError(error, 'Stream request failed');
|
||||||
onError?.(error);
|
onError?.(error);
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ export const downloadStream = async (
|
|||||||
return response;
|
return response;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.error('文件下载失败:', error);
|
console.error('文件下载失败:', error);
|
||||||
handleRequestError(error, '文件下载失败');
|
handleRequestError(error, 'File download failed');
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -33,7 +33,7 @@ export class MovieProjectService {
|
|||||||
): Promise<CreateProjectResponse> {
|
): Promise<CreateProjectResponse> {
|
||||||
try {
|
try {
|
||||||
let apiCall: (p: T) => Promise<QueueResponse>;
|
let apiCall: (p: T) => Promise<QueueResponse>;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case MovieProjectMode.NORMAL:
|
case MovieProjectMode.NORMAL:
|
||||||
apiCall = createMovieProject as (p: T) => Promise<QueueResponse>;
|
apiCall = createMovieProject as (p: T) => Promise<QueueResponse>;
|
||||||
@ -48,34 +48,31 @@ export class MovieProjectService {
|
|||||||
throw new Error(`不支持的创建模式: ${mode}`);
|
throw new Error(`不支持的创建模式: ${mode}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用 withQueuePolling 包装 API 调用
|
|
||||||
const result = await withQueuePolling(apiCall, params, {
|
const result = await withQueuePolling(apiCall, params, {
|
||||||
interval: 5000, // 5秒轮询一次
|
interval: 5000,
|
||||||
maxAttempts: 120, // 最多轮询10分钟
|
maxAttempts: 120,
|
||||||
onPolling: (data: QueueResponseData) => {
|
onPolling: (data: QueueResponseData) => {
|
||||||
console.log("轮询状态:", data);
|
console.log("轮询状态:", data);
|
||||||
},
|
},
|
||||||
onError: (error: Error) => {
|
onError: (error: Error) => {
|
||||||
if (error.message === '操作已取消') {
|
if (error.message === '操作已取消') {
|
||||||
message.info('已取消排队');
|
message.info('Queue cancelled');
|
||||||
} else {
|
} else {
|
||||||
message.error(error instanceof Error ? error.message : "创建项目失败");
|
message.error(error instanceof Error ? error.message : "Failed to create project");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onCancel: () => {
|
onCancel: () => {
|
||||||
message.info('已取消排队');
|
message.info('Queue cancelled');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 处理其他错误状态
|
|
||||||
if (result.code !== 0 && result.code !== 202) {
|
if (result.code !== 0 && result.code !== 202) {
|
||||||
throw new Error(result.message || "创建项目失败");
|
throw new Error(result.message || "Failed to create project");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 从响应中提取 project_id
|
|
||||||
const projectId = (result.data as any).project_id;
|
const projectId = (result.data as any).project_id;
|
||||||
if (!projectId) {
|
if (!projectId) {
|
||||||
throw new Error("创建项目失败:未返回项目ID");
|
throw new Error("Failed to create project: No project ID returned");
|
||||||
}
|
}
|
||||||
|
|
||||||
return { project_id: projectId };
|
return { project_id: projectId };
|
||||||
@ -83,8 +80,8 @@ export class MovieProjectService {
|
|||||||
if (error instanceof Error && error.message === '操作已取消') {
|
if (error instanceof Error && error.message === '操作已取消') {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
message.error(error instanceof Error ? error.message : "创建项目失败");
|
message.error(error instanceof Error ? error.message : "Failed to create project");
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -223,7 +223,7 @@ export function AudioRecorder({
|
|||||||
onAudioRecorded(audioBlob, uploadedUrl);
|
onAudioRecorded(audioBlob, uploadedUrl);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("音频上传失败:", error);
|
console.error("音频上传失败:", error);
|
||||||
message.error("音频上传失败,请重试");
|
message.error("Audio upload failed, please try again");
|
||||||
return;
|
return;
|
||||||
} finally {
|
} finally {
|
||||||
setIsUploadingRecording(false);
|
setIsUploadingRecording(false);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user