From a5ea76a28e87d43e649448ee5da2923ba5b6b0d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=B7=E9=BE=99?= Date: Fri, 29 Aug 2025 01:41:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E5=A0=86=E6=94=B9=E8=8B=B1=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/request.ts | 4 ++-- .../Interaction/MovieProjectService.ts | 23 ++++++++----------- components/ChatInputBox/AudioRecorder.tsx | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/api/request.ts b/api/request.ts index 392738e..c0c4491 100644 --- a/api/request.ts +++ b/api/request.ts @@ -251,7 +251,7 @@ export const stream = async ({ 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; } }; diff --git a/app/service/Interaction/MovieProjectService.ts b/app/service/Interaction/MovieProjectService.ts index 54e99f1..1d4ebb0 100644 --- a/app/service/Interaction/MovieProjectService.ts +++ b/app/service/Interaction/MovieProjectService.ts @@ -33,7 +33,7 @@ export class MovieProjectService { ): Promise { try { let apiCall: (p: T) => Promise; - + switch (mode) { case MovieProjectMode.NORMAL: apiCall = createMovieProject as (p: T) => Promise; @@ -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; } } -} \ No newline at end of file +} diff --git a/components/ChatInputBox/AudioRecorder.tsx b/components/ChatInputBox/AudioRecorder.tsx index 2e35188..e298106 100644 --- a/components/ChatInputBox/AudioRecorder.tsx +++ b/components/ChatInputBox/AudioRecorder.tsx @@ -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);