From cd14ef4ec33e3bd10aab44cda4f7021a32c86112 Mon Sep 17 00:00:00 2001 From: 12975 <1297598740@qq.com> Date: Thu, 29 Jan 2026 23:37:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=EF=BC=8C=E6=94=AF=E6=8C=81=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81=E3=80=81AI=E5=93=8D?= =?UTF-8?q?=E5=BA=94=E3=80=81=E4=BA=A4=E6=98=93=E7=A1=AE=E8=AE=A4/?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E5=8F=8A=E8=AF=AD=E9=9F=B3=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Chat/Chat.css | 14 ++++++++++++++ src/pages/Chat/Chat.tsx | 17 ++++++++++++++++- src/types/index.ts | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/pages/Chat/Chat.css b/src/pages/Chat/Chat.css index 7dc9cde..6f5f84c 100644 --- a/src/pages/Chat/Chat.css +++ b/src/pages/Chat/Chat.css @@ -164,6 +164,20 @@ color: var(--text-primary); } +.confirmation-card-warning { + margin-bottom: 12px; + padding: 10px; + background-color: rgba(245, 158, 11, 0.1); + border: 1px solid #f59e0b; + border-radius: 8px; + color: #b45309; + font-size: 13px; + line-height: 1.5; + display: flex; + align-items: center; + gap: 8px; +} + .confirmation-card-icon { font-size: 18px; } diff --git a/src/pages/Chat/Chat.tsx b/src/pages/Chat/Chat.tsx index 0c35e8d..773d263 100644 --- a/src/pages/Chat/Chat.tsx +++ b/src/pages/Chat/Chat.tsx @@ -111,8 +111,18 @@ export default function Chat() { // 清除会话以开始新对话 aiService.clearSession(); setSessionId(null); - } catch (error) { + } catch (error: any) { console.error('Failed to confirm transaction:', error); + // 显示后端返回的具体错误信息(如余额不足) + const errorMsg = error.response?.data?.error || '抱歉,记账失败,请稍后再试。'; + + const errorMessage: Message = { + id: Date.now().toString(), + role: 'assistant', + content: `❌ ${errorMsg}`, + timestamp: new Date(), + }; + setMessages(prev => [...prev, errorMessage]); } finally { setIsLoading(false); } @@ -281,6 +291,11 @@ export default function Chat() { 📝 确认记账 + {msg.confirmationCard.warning && ( +
+ {msg.confirmationCard.warning} +
+ )}
金额
diff --git a/src/types/index.ts b/src/types/index.ts index 22d0ad5..7912aec 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -481,6 +481,7 @@ export interface ConfirmationCard { date: string; note?: string; isComplete: boolean; + warning?: string; } // AI Transcription Result