feat: 切换Agent自动创建新对话
This commit is contained in:
@@ -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 = `
|
||||
<div class="message-avatar">🔄</div>
|
||||
<div class="message-content" style="color:#667eea;font-size:14px;">
|
||||
已切换到 Agent: <strong>${agentName}</strong>,开始新对话生效
|
||||
// 清空现有内容,显示切换提示
|
||||
container.innerHTML = `
|
||||
<div class="welcome">
|
||||
<h2>🔄 已切换 Agent</h2>
|
||||
<p style="color:#667eea;font-size:18px;"><strong>${agentName}</strong></p>
|
||||
<p style="color:#999;font-size:14px;">已为您创建新对话,可直接开始聊天</p>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(notice);
|
||||
container.scrollTop = container.scrollHeight;
|
||||
|
||||
// 3秒后移除提示
|
||||
setTimeout(() => notice.remove(), 3000);
|
||||
}
|
||||
|
||||
// 加载快捷语句
|
||||
|
||||
Reference in New Issue
Block a user