feat: 添加聊天页面,支持文本消息发送、AI响应、交易确认/取消及语音输入功能
This commit is contained in:
@@ -164,6 +164,20 @@
|
|||||||
color: var(--text-primary);
|
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 {
|
.confirmation-card-icon {
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,8 +111,18 @@ export default function Chat() {
|
|||||||
// 清除会话以开始新对话
|
// 清除会话以开始新对话
|
||||||
aiService.clearSession();
|
aiService.clearSession();
|
||||||
setSessionId(null);
|
setSessionId(null);
|
||||||
} catch (error) {
|
} catch (error: any) {
|
||||||
console.error('Failed to confirm transaction:', error);
|
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 {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
@@ -281,6 +291,11 @@ export default function Chat() {
|
|||||||
<span className="confirmation-card-icon">📝</span>
|
<span className="confirmation-card-icon">📝</span>
|
||||||
确认记账
|
确认记账
|
||||||
</div>
|
</div>
|
||||||
|
{msg.confirmationCard.warning && (
|
||||||
|
<div className="confirmation-card-warning">
|
||||||
|
{msg.confirmationCard.warning}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="confirmation-card-fields">
|
<div className="confirmation-card-fields">
|
||||||
<div className="confirmation-card-field">
|
<div className="confirmation-card-field">
|
||||||
<div className="confirmation-card-label">金额</div>
|
<div className="confirmation-card-label">金额</div>
|
||||||
|
|||||||
@@ -481,6 +481,7 @@ export interface ConfirmationCard {
|
|||||||
date: string;
|
date: string;
|
||||||
note?: string;
|
note?: string;
|
||||||
isComplete: boolean;
|
isComplete: boolean;
|
||||||
|
warning?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AI Transcription Result
|
// AI Transcription Result
|
||||||
|
|||||||
Reference in New Issue
Block a user