refactor(permissions): enhance role-based access controls across knowledge base and agent views

- Updated visibility conditions for various UI elements based on user roles, ensuring that only users with appropriate permissions (Admin, Contributor, or KB creator) can access certain actions.
- Introduced computed properties to manage permissions for sharing knowledge bases, managing data sources, and executing graph extraction.
- Adjusted the AgentList and KnowledgeBase components to reflect these changes, improving user experience by preventing unauthorized actions from being displayed.
- Ensured that the backend routes are aligned with the updated frontend role checks, enhancing security and clarity in user interactions.
This commit is contained in:
wizardchen
2026-05-15 17:56:58 +08:00
committed by lyingbug
parent e7f9a6580a
commit c6a2f6c8cc
9 changed files with 104 additions and 28 deletions
@@ -43,6 +43,7 @@
<div class="setting-control full-width">
<div class="tags-control-group">
<t-button
v-if="canRunGraphExtract"
theme="default"
size="medium"
:disabled="!modelStatus.llm.available"
@@ -79,6 +80,7 @@
<div class="setting-control full-width">
<div class="text-control-group">
<t-button
v-if="canRunGraphExtract"
theme="default"
size="medium"
:disabled="!modelStatus.llm.available"
@@ -266,6 +268,7 @@
<div class="setting-control">
<div class="action-buttons">
<t-button
v-if="canRunGraphExtract"
theme="primary"
:disabled="!modelStatus.llm.available || !localGraphExtract.text"
:loading="extracting"
@@ -298,8 +301,15 @@ import { MessagePlugin } from 'tdesign-vue-next'
import { useI18n } from 'vue-i18n'
import { extractTextRelations, fabriText, fabriTag, type Node, type Relation } from '@/api/initialization'
import { getSystemInfo } from '@/api/system'
import { useAuthStore } from '@/stores/auth'
const { t } = useI18n()
const authStore = useAuthStore()
// canRunGraphExtract 对应后端 POST /initialization/extract/{fabri-tag,fabri-text,
// text-relation} 的 g.Admin() 守卫——这三个都是会调用大模型 + 写库的 admin
// 工具。Contributor 看到按钮点了只会撞 403。
const canRunGraphExtract = computed(() => authStore.hasRole('admin'))
interface GraphExtractConfig {
enabled: boolean