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 @@ + + + + + + + 机器人设置 + × + + + + + + {{ bot.avatar || '🤖' }} + + {{ bot.display_name || bot.name }} + + {{ bot.status === 'online' ? '🟢 在线' : '⚪ 离线' }} + + + + + + + 绑定 Agent + 选择一个在线的 Agent 来启用此机器人 + + + + + 🤖 + + {{ agent.display_name || agent.name }} + + {{ agent.status === 'online' ? '在线' : '离线' }} + + + + + + + 暂无可用 Agent + 请确保至少有一个 Agent 在线 + + + + + + {{ error }} + + + + + + 解绑 + + + {{ loading ? '处理中...' : '绑定' }} + + + + + + + + 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 +} @@ -53,7 +70,10 @@ function handleBotCreated(bot: any) { - 选择机器人开始聊天 + + 选择机器人开始聊天 + {{ chatStore.bots.length }} 个机器人 + + + ⚙️ + @@ -110,6 +136,13 @@ function handleBotCreated(bot: any) { @close="showCreateBot = false" @created="handleBotCreated" /> + + @@ -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;
+ {{ bot.status === 'online' ? '🟢 在线' : '⚪ 离线' }} +
选择一个在线的 Agent 来启用此机器人
暂无可用 Agent
请确保至少有一个 Agent 在线