fix(知识库): 同步dify知识库bug修复
This commit is contained in:
1 parent
4ce4d75524
commit
fcb2f88f1a
1 file changed
+22
-1
@@ -237,6 +237,8 @@ const draggedSectionIndex = ref<number | null>(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);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user