diff --git a/frontend/dist/index.html b/frontend/dist/index.html index 88a1fad1..2e243d12 100644 --- a/frontend/dist/index.html +++ b/frontend/dist/index.html @@ -10,8 +10,8 @@ AI工作台 - - + +
diff --git a/frontend/src/views/ChatView.vue b/frontend/src/views/ChatView.vue index 50e893c4..b2f48af2 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, LayoutGrid, UserCircle } 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, History, MoreVertical } from 'lucide-vue-next'; import { marked } from 'marked'; import { useRoute, useRouter } from 'vue-router'; import { config } from '../config'; @@ -26,6 +26,21 @@ import { getAuthHeaders, getStoredAuthUser, clearAuthUser } from '../utils/auth' const { t } = useI18n(); const { showMessageDialog } = useGlobalMessageDialog(); const { isMobile } = useIsMobile(); +const showMobileAgentPopover = ref(false); +const mobileAgentPopoverRef = ref(null); + +const handleMobileAgentPopoverClickOutside = (e: MouseEvent | TouchEvent) => { + if (mobileAgentPopoverRef.value && !mobileAgentPopoverRef.value.contains(e.target as Node)) { + showMobileAgentPopover.value = false; + } +}; + +const toggleMobileAgentPopover = () => { + showMobileAgentPopover.value = !showMobileAgentPopover.value; + if (showMobileAgentPopover.value) { + loadUserAgents(); + } +}; const currentUser = ref(getStoredAuthUser()); const showUserDropdown = ref(false); const userMenuRef = ref(null); @@ -1662,6 +1677,8 @@ const switchToAgent = (agent: { id: number; name: string }) => { onMounted(async () => { document.addEventListener('mousedown', handleDocumentPointerDown); document.addEventListener('touchstart', handleDocumentPointerDown, { passive: true }); + document.addEventListener('mousedown', handleMobileAgentPopoverClickOutside); + document.addEventListener('touchstart', handleMobileAgentPopoverClickOutside, { passive: true }); window.addEventListener('resize', syncViewportWidth); await syncCurrentUserProfile(); await loadAgent(); @@ -1681,6 +1698,8 @@ onMounted(async () => { onBeforeUnmount(() => { document.removeEventListener('mousedown', handleDocumentPointerDown); document.removeEventListener('touchstart', handleDocumentPointerDown); + document.removeEventListener('mousedown', handleMobileAgentPopoverClickOutside); + document.removeEventListener('touchstart', handleMobileAgentPopoverClickOutside); window.removeEventListener('resize', syncViewportWidth); stopBrowserResize(); if (scrollToBottomFrame !== null) { @@ -1873,9 +1892,29 @@ const showChatRating = ref(false);
AI
{{ currentAgent?.name || 'AI' }} - +
+ + +
+
+
智能体
+ +
暂无其他智能体
+
diff --git a/frontend/src/views/WorkspaceView.vue b/frontend/src/views/WorkspaceView.vue index f2b4993c..d4fad072 100644 --- a/frontend/src/views/WorkspaceView.vue +++ b/frontend/src/views/WorkspaceView.vue @@ -48,8 +48,7 @@ import { Megaphone, X, ChevronDown, - ChevronUp, - MessageCircle + ChevronUp } from 'lucide-vue-next'; import KbWorkspaceView from './KbWorkspaceView.vue'; @@ -320,7 +319,7 @@ const fetchHome = async () => { defaultSections.forEach(d => { if (!backendIds.has(d.id)) { if (config.workspace.modules[mapKey(d.id) as keyof typeof config.workspace.modules] === false) { - return; +return; } merged.push(d); } @@ -771,7 +770,7 @@ const handleRegister = async () => { } }; -const activeSidebarItem = ref<'profile' | 'applications' | 'feedback' | 'updates' | 'knowledge_base' | 'schedule_runs'>('applications'); +const activeSidebarItem = ref<'profile' | 'applications' | 'feedback' | 'updates' | 'knowledge_base' | 'schedule_runs' | 'history'>('applications'); const isProfileLoading = ref(false); const isProfileSaving = ref(false); const isProfileEditing = ref(false); @@ -817,15 +816,16 @@ const hasProfileUnsavedChanges = computed(() => { const mobileTabActive = computed({ get: () => { if (activeSidebarItem.value === 'profile') return 'profile'; - if (activeSidebarItem.value === 'feedback') return 'feedback'; + if (activeSidebarItem.value === 'history') return 'history'; return 'applications'; }, - set: (tab: 'applications' | 'feedback' | 'profile') => { + set: (tab: 'applications' | 'profile' | 'history') => { if (tab === 'profile') { activeSidebarItem.value = 'profile'; if (!profileUser.value.id) fetchProfile(); - } else if (tab === 'feedback') { - activeSidebarItem.value = 'feedback'; + } else if (tab === 'history') { + activeSidebarItem.value = 'history'; + if (chatHistories.value.length === 0) loadChatHistories(); } else { activeSidebarItem.value = 'applications'; } @@ -834,7 +834,7 @@ const mobileTabActive = computed({ const mobileTabTitle = computed(() => { if (mobileTabActive.value === 'profile') return '我的'; - if (mobileTabActive.value === 'feedback') return '意见反馈'; + if (mobileTabActive.value === 'history') return '历史会话'; return '应用管理'; }); @@ -1117,6 +1117,43 @@ const downloadWsScheduleExcel = async (runId: number) => { URL.revokeObjectURL(url); }; +interface ChatHistoryItem { + id: number; + conversation_id: string; + title: string; + agent_id?: number; + agent_name?: string; + created_at: string; +} +const chatHistories = ref([]); +const isLoadingHistories = ref(false); + +const loadChatHistories = async () => { + isLoadingHistories.value = true; + try { + const res = await fetch('/api/agents', { headers: getAuthHeaders() }); + if (!res.ok) { isLoadingHistories.value = false; return; } + const agentList = await res.json(); + const allHistories: ChatHistoryItem[] = []; + await Promise.all( + (Array.isArray(agentList) ? agentList : []).map(async (agent: any) => { + try { + const hRes = await fetch(`/api/chat/sessions?agent_id=${agent.id}`, { headers: getAuthHeaders() }); + if (hRes.ok) { + const sessions = await hRes.json(); + for (const s of sessions) { + allHistories.push({ ...s, agent_id: agent.id, agent_name: agent.name }); + } + } + } catch {} + }) + ); + allHistories.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()); + chatHistories.value = allHistories; + } catch {} + isLoadingHistories.value = false; +}; + const navigateToGeneralChat = () => { router.push(`/chat/${DEFAULT_POST_LOGIN_AGENT_ID}`); }; @@ -1331,12 +1368,15 @@ onMounted(async () => { await fetchHome(); await handleWecomDeeplinkContext(); const viewParam = route.query.view as string; - const validViews: string[] = ['profile', 'applications', 'feedback', 'updates', 'knowledge_base', 'schedule_runs']; + const validViews: string[] = ['profile', 'applications', 'feedback', 'updates', 'knowledge_base', 'schedule_runs', 'history']; if (viewParam && validViews.includes(viewParam)) { activeSidebarItem.value = viewParam as typeof activeSidebarItem.value; if (viewParam === 'profile' && !profileUser.value.id) { await fetchProfile(); } + if (viewParam === 'history') { + await loadChatHistories(); + } } } else { await fetchPublicAgents(); @@ -1384,7 +1424,7 @@ onMounted(async () => {