From 021ce8b50be3d679972b043fccca03402e8da07d Mon Sep 17 00:00:00 2001 From: "feifei.xu" <307327147@qq.com> Date: Sun, 15 Mar 2026 11:59:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8A=9F=E8=83=BD2=20-=20=E7=BB=91?= =?UTF-8?q?=E5=AE=9A/=E8=A7=A3=E7=BB=91=20Agent=20(v0.9.7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 BotSettingsModal.vue 机器人设置模态框 - 显示在线 Agent 列表 - 实现 Agent 绑定功能 - 实现 Agent 解绑功能 - HomeView 添加设置按钮(hover 显示) - Store 添加 bindBotAgent 方法 - 显示机器人绑定状态 --- .../src/components/chat/BotSettingsModal.vue | 410 ++++++++++++++++++ frontend/src/views/HomeView.vue | 79 +++- 2 files changed, 485 insertions(+), 4 deletions(-) create mode 100644 frontend/src/components/chat/BotSettingsModal.vue diff --git a/frontend/src/components/chat/BotSettingsModal.vue b/frontend/src/components/chat/BotSettingsModal.vue new file mode 100644 index 0000000..8b7ee92 --- /dev/null +++ b/frontend/src/components/chat/BotSettingsModal.vue @@ -0,0 +1,410 @@ + + + + + diff --git a/frontend/src/views/HomeView.vue b/frontend/src/views/HomeView.vue index 1cbe993..ac23a4c 100644 --- a/frontend/src/views/HomeView.vue +++ b/frontend/src/views/HomeView.vue @@ -2,14 +2,17 @@ import { ref, onMounted } from 'vue' import { useRouter } from 'vue-router' import { useAuthStore } from '@/stores/auth' -import { useChatStore } from '@/stores/chat' +import { useChatStore, type Bot } from '@/stores/chat' import CreateBotModal from '@/components/chat/CreateBotModal.vue' +import BotSettingsModal from '@/components/chat/BotSettingsModal.vue' const router = useRouter() const authStore = useAuthStore() const chatStore = useChatStore() const showCreateBot = ref(false) +const showBotSettings = ref(false) +const selectedBot = ref(null) onMounted(async () => { await chatStore.fetchBots() @@ -28,9 +31,23 @@ function resumeChat(sessionId: string) { router.push({ name: 'chat', params: { sessionId } }) } -function handleBotCreated(bot: any) { +function handleBotCreated(bot: Bot) { chatStore.bots.push(bot) } + +function openBotSettings(bot: Bot, event: Event) { + event.stopPropagation() + selectedBot.value = bot + showBotSettings.value = true +} + +function handleBotUpdated(bot: Bot) { + const index = chatStore.bots.findIndex(b => b.id === bot.id) + if (index !== -1) { + chatStore.bots[index] = bot + } + selectedBot.value = bot +} @@ -192,11 +225,22 @@ function handleBotCreated(bot: any) { margin-bottom: var(--spacing-xl); } +.section-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: var(--spacing-md); +} + .section-title { font-size: var(--font-size-md); font-weight: 600; color: var(--text-primary); - margin-bottom: var(--spacing-md); +} + +.bot-count { + font-size: var(--font-size-sm); + color: var(--text-tertiary); } .bot-grid { @@ -214,6 +258,7 @@ function handleBotCreated(bot: any) { gap: var(--spacing-md); cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; + position: relative; } .bot-card:hover { @@ -221,6 +266,32 @@ function handleBotCreated(bot: any) { box-shadow: var(--shadow-md); } +.settings-btn { + position: absolute; + top: 8px; + right: 8px; + width: 28px; + height: 28px; + border: none; + background: var(--bg-tertiary); + border-radius: 50%; + cursor: pointer; + display: flex; + align-items: center; + justify-content: center; + font-size: 12px; + opacity: 0; + transition: opacity 0.2s; +} + +.bot-card:hover .settings-btn { + opacity: 1; +} + +.settings-btn:hover { + background: var(--bg-primary); +} + .bot-avatar { width: 48px; height: 48px;