feat: 添加聊天页面,支持文本消息发送、AI响应、交易确认/取消及语音输入功能
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
<span className="confirmation-card-icon">📝</span>
|
||||
确认记账
|
||||
</div>
|
||||
{msg.confirmationCard.warning && (
|
||||
<div className="confirmation-card-warning">
|
||||
{msg.confirmationCard.warning}
|
||||
</div>
|
||||
)}
|
||||
<div className="confirmation-card-fields">
|
||||
<div className="confirmation-card-field">
|
||||
<div className="confirmation-card-label">金额</div>
|
||||
|
||||
@@ -481,6 +481,7 @@ export interface ConfirmationCard {
|
||||
date: string;
|
||||
note?: string;
|
||||
isComplete: boolean;
|
||||
warning?: string;
|
||||
}
|
||||
|
||||
// AI Transcription Result
|
||||
|
||||
Reference in New Issue
Block a user