From fcb2f88f1a94faaa00e828a7dc54ef23bd804105 Mon Sep 17 00:00:00 2001 From: "DESKTOP-JKIE562\\PC" <1013397054@qq.com> Date: Mon, 8 Jun 2026 15:56:40 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=9F=A5=E8=AF=86=E5=BA=93):=20=E5=90=8C?= =?UTF-8?q?=E6=AD=A5dify=E7=9F=A5=E8=AF=86=E5=BA=93bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/WorkspaceView.vue | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/WorkspaceView.vue b/frontend/src/views/WorkspaceView.vue index 042c9d07..1c4cd8b3 100644 --- a/frontend/src/views/WorkspaceView.vue +++ b/frontend/src/views/WorkspaceView.vue @@ -237,6 +237,8 @@ const draggedSectionIndex = ref(null); // Computed const isLoggedIn = computed(() => !!currentUser.value && currentUser.value.role !== 'guest'); +const hasKnowledgeBaseAccess = computed(() => String(currentUser.value?.username || '').trim().toLowerCase() === 'admin'); +const KB_ACCESS_DENIED_MESSAGE = '暂无权限,请登录admin账号操作知识库!'; const favoriteAgents = computed(() => { return agents.value.filter(a => favoriteAgentIds.value.includes(a.id)); @@ -975,7 +977,15 @@ const navigateToApplications = () => openWorkspaceSection('favorites', 'applicat const navigateToUpdates = () => openWorkspaceSection('announcements', 'updates'); +const showKnowledgeBaseAccessDenied = () => { + msg.warning(KB_ACCESS_DENIED_MESSAGE); +}; + const navigateToKnowledgeBase = () => { + if (!hasKnowledgeBaseAccess.value) { + showKnowledgeBaseAccessDenied(); + return; + } activeSidebarItem.value = 'knowledge_base'; }; @@ -1339,7 +1349,12 @@ onMounted(async () => { const viewParam = route.query.view as string; 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 === 'knowledge_base' && !hasKnowledgeBaseAccess.value) { + showKnowledgeBaseAccessDenied(); + activeSidebarItem.value = 'applications'; + } else { + activeSidebarItem.value = viewParam as typeof activeSidebarItem.value; + } if (viewParam === 'profile' && !profileUser.value.id) { await fetchProfile(); } @@ -1353,6 +1368,12 @@ onMounted(async () => { } }); +watch(hasKnowledgeBaseAccess, (allowed) => { + if (!allowed && activeSidebarItem.value === 'knowledge_base') { + activeSidebarItem.value = 'applications'; + } +}); + onBeforeUnmount(() => { window.removeEventListener('hxops:logout', onAuthLogout); });