fix: 智能体使用记录改为发送第一条消息时才记录

This commit is contained in:
2026-04-26 23:52:14 +08:00
parent e6b3465aa7
commit 0303ccabc0
2 changed files with 8 additions and 6 deletions

View File

@@ -634,9 +634,6 @@ function openAgent(agentId) {
currentAgent = agents.find(a => a.id === agentId); currentAgent = agents.find(a => a.id === agentId);
if (!currentAgent) return; if (!currentAgent) return;
// 记录智能体使用历史
recordAgentUsage(agentId);
// 创建新对话并设置智能体 // 创建新对话并设置智能体
createNewConversation(); createNewConversation();
currentConversation.agentId = agentId; currentConversation.agentId = agentId;
@@ -1565,6 +1562,11 @@ async function sendMessage() {
// 隐藏欢迎界面 // 隐藏欢迎界面
welcome.style.display = 'none'; welcome.style.display = 'none';
// 如果是智能体对话的第一条消息,记录智能体使用
if (currentConversation.agentId && currentConversation.messages.length === 0) {
recordAgentUsage(currentConversation.agentId);
}
// 添加用户消息 // 添加用户消息
currentConversation.messages.push({ role: 'user', content: text }); currentConversation.messages.push({ role: 'user', content: text });

View File

@@ -8,12 +8,12 @@
<meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0"> <meta http-equiv="Expires" content="0">
<title>AI助手</title> <title>AI助手</title>
<link rel="stylesheet" href="style.css?v=3.1.1"> <link rel="stylesheet" href="style.css?v=3.1.2">
<link rel="manifest" href="manifest.json"> <link rel="manifest" href="manifest.json">
</head> </head>
<body> <body>
<div id="app"></div> <div id="app"></div>
<script src="marked.min.js?v=3.1.1"></script> <script src="marked.min.js?v=3.1.2"></script>
<script src="app.js?v=3.1.1"></script> <script src="app.js?v=3.1.2"></script>
</body> </body>
</html> </html>