From 051fd5c1c88e2ea91639af1575c04569a4b7bc69 Mon Sep 17 00:00:00 2001 From: hubian <908234780@qq.com> Date: Sun, 12 Apr 2026 17:01:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=87=E6=8D=A2Agent=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=88=9B=E5=BB=BA=E6=96=B0=E5=AF=B9=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/index.html | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/templates/index.html b/templates/index.html index 5c18947..56259fc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -206,10 +206,11 @@ } } - // 切换Agent - function switchAgent() { + // 切换Agent - 自动创建新对话 + async function switchAgent() { const newAgentId = document.getElementById('agentSelect').value; - if (newAgentId && newAgentId !== currentAgentId) { + if (newAgentId && parseInt(newAgentId) !== currentAgentId) { + const oldAgentId = currentAgentId; currentAgentId = parseInt(newAgentId); console.log('切换Agent:', currentAgentId); @@ -221,6 +222,9 @@ })); } + // 自动创建新对话 + await createNewConversation(); + // 显示切换提示 const agent = agents.find(a => a.id === currentAgentId); if (agent) { @@ -232,19 +236,14 @@ // 显示Agent切换提示 function showAgentSwitchNotice(agentName) { const container = document.getElementById('messagesContainer'); - const notice = document.createElement('div'); - notice.className = 'message assistant'; - notice.innerHTML = ` -
🔄
-
- 已切换到 Agent: ${agentName},开始新对话生效 + // 清空现有内容,显示切换提示 + container.innerHTML = ` +
+

🔄 已切换 Agent

+

${agentName}

+

已为您创建新对话,可直接开始聊天

`; - container.appendChild(notice); - container.scrollTop = container.scrollHeight; - - // 3秒后移除提示 - setTimeout(() => notice.remove(), 3000); } // 加载快捷语句