diff --git a/frontend/src/views/ChatView.vue b/frontend/src/views/ChatView.vue index c00c12e3..16a41d6c 100644 --- a/frontend/src/views/ChatView.vue +++ b/frontend/src/views/ChatView.vue @@ -13,7 +13,7 @@ import { ref, onMounted, onBeforeUnmount, computed, watch, nextTick } from 'vue'; import { useI18n } from 'vue-i18n'; import { useChat } from '../composables/useChat'; -import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, Heart, Bell, Mail, Settings, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search } from 'lucide-vue-next'; +import { Send, Loader2, Plus, Copy, Edit2, RotateCw, Check, X, PanelLeftClose, PanelLeftOpen, Heart, Bell, Mail, Settings, ChevronDown, Sparkles, Database, Mic, LogOut, MessageSquareText, Globe, ExternalLink, Search, LayoutGrid } from 'lucide-vue-next'; import { marked } from 'marked'; import { useRoute, useRouter } from 'vue-router'; import { config } from '../config'; @@ -571,7 +571,9 @@ const copiedIndex = ref(null); const { messages, isThinking, conversationId, sendMessage } = useChat(); const input = ref(''); const currentAgent = ref(null); +const userAgents = ref>([]); const showGeneralFeedbackDialog = ref(false); +const showAgentPanel = ref(true); const OA_BASE_URL = 'http://oa.well-trust.com:8888'; const OA_LOGIN_URL = `${OA_BASE_URL}/login/Login.jsp?logintype=1`; @@ -1535,6 +1537,28 @@ const loadAgent = async () => { } }; +const loadUserAgents = async () => { + try { + const res = await fetch('/api/agents', { headers: getAuthHeaders() }); + if (res.ok) { + const agents = await res.json(); + userAgents.value = Array.isArray(agents) ? agents.filter((a: any) => a.id !== agentId) : []; + if (userAgents.value.length === 0) { + showAgentPanel.value = false; + } + } + } catch (e) { + userAgents.value = []; + showAgentPanel.value = false; + } +}; + +const switchToAgent = (agent: { id: number; name: string }) => { + if (agent.id === agentId) return; + const url = router.resolve(`/chat/${agent.id}`).href; + window.open(url, '_blank'); +}; + // 组件挂载时,如果存在预设问题,则自动触发一次发送 onMounted(async () => { document.addEventListener('mousedown', handleDocumentPointerDown); @@ -1542,6 +1566,7 @@ onMounted(async () => { window.addEventListener('resize', syncViewportWidth); await syncCurrentUserProfile(); await loadAgent(); + await loadUserAgents(); await loadHistory(); @@ -1680,21 +1705,23 @@ const showChatRating = ref(false);
-
@@ -1722,6 +1749,7 @@ const showChatRating = ref(false);
+