From 1af5fda76a5d9953bc81be19938d168b95d9409a Mon Sep 17 00:00:00 2001 From: Zixin Zhou Date: Thu, 28 Aug 2025 20:57:57 +0800 Subject: [PATCH 1/2] I am so sad today --- components/layout/top-bar.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/layout/top-bar.tsx b/components/layout/top-bar.tsx index f72539d..f003157 100644 --- a/components/layout/top-bar.tsx +++ b/components/layout/top-bar.tsx @@ -99,12 +99,12 @@ export function TopBar({ if (response.successful && response.data?.portal_url) { redirectToPortal(response.data.portal_url); } else { - console.error('创建订阅管理会话失败:', response.message); - alert('无法打开订阅管理页面,请稍后重试'); + console.log("cannot open the manage subscription"); + return; } } catch (error) { - console.error('打开订阅管理页面失败:', error); - alert('无法打开订阅管理页面,请稍后重试'); + console.log("cannot open the manage subscription"); + return; } finally { setIsManagingSubscription(false); } From 3c571314432fc7b9e4676b1df7e8988b6d498317 Mon Sep 17 00:00:00 2001 From: Zixin Zhou Date: Thu, 28 Aug 2025 22:11:20 +0800 Subject: [PATCH 2/2] update transformMessage --- components/SmartChatBox/api.ts | 5 +++-- components/SmartChatBox/types.ts | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/components/SmartChatBox/api.ts b/components/SmartChatBox/api.ts index d1a67a6..11b6363 100644 --- a/components/SmartChatBox/api.ts +++ b/components/SmartChatBox/api.ts @@ -208,7 +208,7 @@ function transformSystemMessage( */ function transformMessage(apiMessage: RealApiMessage): ChatMessage { try { - const { id, role, content, created_at, function_name, custom_data, status, intent_type, error_message } = apiMessage; + const { id, role, content, created_at, function_name, custom_data, status, intent_type } = apiMessage; let message: ChatMessage = { id: id ? id.toString() : Date.now().toString(), role: role, @@ -218,7 +218,8 @@ function transformMessage(apiMessage: RealApiMessage): ChatMessage { status: status || 'success', }; - if (error_message && error_message === 'no enough credits') { + const errorMessage = custom_data?.error_message; + if (errorMessage && errorMessage === 'no enough credits') { message.blocks = NoEnoughCreditsMessageBlocks; } else { if (role === 'assistant' || role === 'user') { diff --git a/components/SmartChatBox/types.ts b/components/SmartChatBox/types.ts index 3587c56..c9a1040 100644 --- a/components/SmartChatBox/types.ts +++ b/components/SmartChatBox/types.ts @@ -131,14 +131,19 @@ export interface ApiMessageContent { url?: string; } +interface BaseCustomData { + error_message?: string; + rejected_reason?: string; + [key: string]: any; +} + export interface RealApiMessage { created_at: string; id: number; role: Role; content: string; function_name?: FunctionName; - custom_data?: ProjectInit | ScriptSummary | CharacterGeneration | SketchGeneration | ShotSketchGeneration | ShotVideoGeneration; + custom_data?: (ProjectInit | ScriptSummary | CharacterGeneration | SketchGeneration | ShotSketchGeneration | ShotVideoGeneration) & BaseCustomData; status: MessageStatus; intent_type: IntentType; - error_message?: string; } \ No newline at end of file