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