From 1af5b33ccc28e1b23da2c83f71e43ee6048eefbf Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Tue, 17 Mar 2026 00:58:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E5=AE=9E=E7=8E=B0=E6=99=AE?= =?UTF-8?q?=E9=80=9A=E7=94=A8=E6=88=B7=E5=92=8C=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E5=B7=AE=E5=BC=82=E5=8C=96=E6=9D=83=E9=99=90=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 知识库API区分:管理员调用getDatabases,普通用户调用getAccessibleDatabases - UI权限控制:隐藏普通用户的顶部导航栏、知识库管理、任务中心等管理员功能 - 路由调整:普通用户可访问/agent页面,移除requiresAdmin限制 - 代码优化:删除AgentSingleView.vue,合并到AgentView.vue统一处理 - 错误处理增强:AppLayout中增加配置和知识库加载的try-catch --- web/src/apis/knowledge_api.js | 4 +- web/src/components/AgentChatComponent.vue | 65 +++- web/src/components/ChatSidebarComponent.vue | 34 +- web/src/layouts/AppLayout.vue | 89 +++-- web/src/router/index.js | 24 +- web/src/stores/config.js | 10 +- web/src/stores/database.js | 10 +- web/src/stores/tasker.js | 9 + web/src/views/AgentSingleView.vue | 376 -------------------- web/src/views/AgentView.vue | 78 +++- web/src/views/LoginView.vue | 30 +- 11 files changed, 248 insertions(+), 481 deletions(-) delete mode 100644 web/src/views/AgentSingleView.vue diff --git a/web/src/apis/knowledge_api.js b/web/src/apis/knowledge_api.js index 75834f44..9fda90f9 100644 --- a/web/src/apis/knowledge_api.js +++ b/web/src/apis/knowledge_api.js @@ -1,4 +1,4 @@ -import { apiAdminGet, apiAdminPost, apiAdminPut, apiAdminDelete, apiRequest } from './base' +import { apiGet, apiAdminGet, apiAdminPost, apiAdminPut, apiAdminDelete, apiRequest } from './base' /** * 知识库管理API模块 @@ -75,7 +75,7 @@ export const databaseApi = { * @returns {Promise} - 可访问的知识库列表 */ getAccessibleDatabases: async () => { - return apiAdminGet('/api/knowledge/databases/accessible') + return apiGet('/api/knowledge/databases/accessible') } } diff --git a/web/src/components/AgentChatComponent.vue b/web/src/components/AgentChatComponent.vue index 32be7e80..89386291 100644 --- a/web/src/components/AgentChatComponent.vue +++ b/web/src/components/AgentChatComponent.vue @@ -27,10 +27,22 @@
+
@@ -52,6 +64,7 @@
+
@@ -219,6 +232,8 @@ import { ScrollController } from '@/utils/scrollController' import { AgentValidator } from '@/utils/agentValidator' import { useAgentStore } from '@/stores/agent' import { useChatUIStore } from '@/stores/chatUI' +import { useInfoStore } from '@/stores/info' +import { useUserStore } from '@/stores/user' import { storeToRefs } from 'pinia' import { MessageProcessor } from '@/utils/messageProcessor' import { agentApi, threadApi } from '@/apis' @@ -226,6 +241,7 @@ import HumanApprovalModal from '@/components/HumanApprovalModal.vue' import { useApproval } from '@/composables/useApproval' import { useAgentStreamHandler } from '@/composables/useAgentStreamHandler' import AgentPanel from '@/components/AgentPanel.vue' +import UserInfoComponent from '@/components/UserInfoComponent.vue' // ==================== PROPS & EMITS ==================== const props = defineProps({ @@ -236,6 +252,8 @@ const props = defineProps({ // ==================== STORE MANAGEMENT ==================== const agentStore = useAgentStore() const chatUIStore = useChatUIStore() +const infoStore = useInfoStore() +const userStore = useUserStore() const { agents, selectedAgentId, @@ -247,9 +265,11 @@ const { availableMcps, availableSkills } = storeToRefs(agentStore) +const { organization } = storeToRefs(infoStore) // ==================== LOCAL CHAT & UI STATE ==================== const userInput = ref('') +const sidebarLogo = computed(() => organization.value?.logo || organization.value?.avatar || '') const useRunsApi = import.meta.env.VITE_USE_RUNS_API === 'true' && localStorage.getItem('force_legacy_stream') !== 'true' @@ -1910,6 +1930,7 @@ watch( .header__right { display: flex; align-items: center; + gap: 8px; } .switch-icon { @@ -1920,6 +1941,48 @@ watch( .agent-nav-btn:hover .switch-icon { color: var(--main-500); } + + .sidebar-logo-toggle { + position: relative; + width: 32px; + height: 32px; + border-radius: 8px; + border: 1px solid var(--gray-150); + background: var(--gray-0); + display: flex; + align-items: center; + justify-content: center; + overflow: hidden; + cursor: pointer; + flex-shrink: 0; + } + + .sidebar-logo-image { + width: 24px; + height: 24px; + border-radius: 6px; + object-fit: cover; + } + + .sidebar-logo-fallback { + color: var(--gray-700); + } + + .sidebar-expand-overlay { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: center; + background: var(--gray-100); + color: var(--gray-900); + opacity: 0; + transition: opacity 0.2s ease; + } + + .sidebar-logo-toggle:hover .sidebar-expand-overlay { + opacity: 1; + } } } diff --git a/web/src/components/ChatSidebarComponent.vue b/web/src/components/ChatSidebarComponent.vue index 8941dbc9..c24da204 100644 --- a/web/src/components/ChatSidebarComponent.vue +++ b/web/src/components/ChatSidebarComponent.vue @@ -5,7 +5,15 @@ >