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