feat(config): 在前端添加基于权限的知识库展示设计
This commit is contained in:
parent
7ffc7a7920
commit
3b903bcef4
@ -75,9 +75,6 @@ class BaseContext:
|
||||
default_factory=list,
|
||||
metadata={
|
||||
"name": "知识库",
|
||||
"options": lambda: [
|
||||
{"name": k["name"], "description": k["description"]} for k in knowledge_base.get_retrievers().values()
|
||||
],
|
||||
"description": "知识库列表,可以在左侧知识库页面中创建知识库。",
|
||||
"type": "list", # Explicitly mark as list type for frontend if needed
|
||||
},
|
||||
|
||||
@ -1368,7 +1368,7 @@ watch(
|
||||
<style lang="less">
|
||||
.agent-nav-btn {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
gap: 6px;
|
||||
padding: 6px 8px;
|
||||
height: 32px;
|
||||
justify-content: center;
|
||||
|
||||
@ -365,16 +365,17 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, computed, nextTick } from 'vue'
|
||||
import { ref, computed, nextTick, watch } from 'vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { X, Trash2, Check, Plus, Search, Star } from 'lucide-vue-next'
|
||||
import ModelSelectorComponent from '@/components/ModelSelectorComponent.vue'
|
||||
import { useAgentStore } from '@/stores/agent'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useDatabaseStore } from '@/stores/database'
|
||||
import { storeToRefs } from 'pinia'
|
||||
|
||||
// Props
|
||||
defineProps({
|
||||
const props = defineProps({
|
||||
isOpen: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
@ -391,6 +392,17 @@ const emit = defineEmits(['close'])
|
||||
// Store 管理
|
||||
const agentStore = useAgentStore()
|
||||
const userStore = useUserStore()
|
||||
const databaseStore = useDatabaseStore()
|
||||
|
||||
watch(
|
||||
() => props.isOpen,
|
||||
(val) => {
|
||||
if (val) {
|
||||
databaseStore.loadDatabases().catch(() => {})
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
const {
|
||||
availableTools,
|
||||
selectedAgent,
|
||||
@ -455,6 +467,9 @@ const getConfigOptions = (value) => {
|
||||
if (value?.template_metadata?.kind === 'tools') {
|
||||
return availableTools.value ? Object.values(availableTools.value) : []
|
||||
}
|
||||
if (value?.template_metadata?.kind === 'knowledges') {
|
||||
return databaseStore.databases || []
|
||||
}
|
||||
return value?.options || []
|
||||
}
|
||||
|
||||
@ -603,6 +618,14 @@ const openSelectionModal = async (key) => {
|
||||
console.error('刷新工具列表失败:', error)
|
||||
}
|
||||
}
|
||||
// 如果是知识库,需要获取知识库列表
|
||||
if (configurableItems.value[key]?.template_metadata?.kind === 'knowledges') {
|
||||
try {
|
||||
await databaseStore.loadDatabases()
|
||||
} catch (error) {
|
||||
console.error('加载知识库列表失败:', error)
|
||||
}
|
||||
}
|
||||
const currentValues = agentConfig.value[key] || []
|
||||
tempSelectedValues.value = [...currentValues]
|
||||
selectionModalOpen.value = true
|
||||
@ -833,6 +856,10 @@ const confirmDeleteConfig = async () => {
|
||||
border: 1px solid var(--gray-100);
|
||||
// box-shadow: 0px 0px 2px var(--shadow-3);
|
||||
|
||||
:deep(.ant-form-item-label > label) {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:deep(label.form_item_model) {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ export const useDatabaseStore = defineStore('database', () => {
|
||||
} catch (error) {
|
||||
console.error('加载数据库列表失败:', error)
|
||||
if (error.message.includes('权限')) {
|
||||
message.error('需要管理员权限访问知识库')
|
||||
message.error('没有权限访问知识库')
|
||||
}
|
||||
throw error
|
||||
} finally {
|
||||
|
||||
@ -150,12 +150,10 @@
|
||||
<ShareAltOutlined class="menu-icon" />
|
||||
<span class="menu-text">分享对话</span>
|
||||
</div>
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item" @click="handleFeedback">
|
||||
<MessageOutlined class="menu-icon" />
|
||||
<span class="menu-text">查看反馈</span>
|
||||
</div>
|
||||
<div class="menu-divider"></div>
|
||||
<div class="menu-item" @click="handlePreview">
|
||||
<EyeOutlined class="menu-icon" />
|
||||
<span class="menu-text">预览页面</span>
|
||||
@ -976,21 +974,21 @@ const handlePreview = () => {
|
||||
// 自定义更多菜单样式
|
||||
.more-popup-menu {
|
||||
position: fixed;
|
||||
min-width: 130px;
|
||||
min-width: 100px;
|
||||
background: var(--gray-0);
|
||||
border-radius: 10px;
|
||||
box-shadow:
|
||||
0 8px 24px rgba(0, 0, 0, 0.08),
|
||||
0 2px 8px rgba(0, 0, 0, 0.04);
|
||||
border: 1px solid var(--gray-100);
|
||||
padding: 6px;
|
||||
padding: 4px;
|
||||
z-index: 9999;
|
||||
|
||||
.menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 6px 14px;
|
||||
padding: 6px 8px;
|
||||
border-radius: 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user