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