(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 () => {