mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-26 10:12:51 +00:00
feat: resource
This commit is contained in:
parent
d90805acbb
commit
f3fff4a26e
|
|
@ -172,22 +172,6 @@ const putSyncWebKnowledge: (
|
|||
return put(`${prefix}/${knowledge_id}/sync`, undefined, { sync_type }, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建知识库
|
||||
* @param 参数
|
||||
* {
|
||||
"name": "string",
|
||||
"folder_id": "string",
|
||||
"desc": "string",
|
||||
"embedding": "string"
|
||||
}
|
||||
*/
|
||||
const postKnowledge: (data: knowledgeData, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
data,
|
||||
loading,
|
||||
) => {
|
||||
return post(`${prefix}/base`, data, undefined, loading, 1000 * 60 * 5)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户可使用的向量化模型列表(没用到)
|
||||
|
|
@ -214,33 +198,6 @@ const getKnowledgeModel: (loading?: Ref<boolean>) => Promise<Result<Array<any>>>
|
|||
return get(`${prefix}/model`, loading)
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建Web知识库
|
||||
* @param 参数
|
||||
* {
|
||||
"name": "string",
|
||||
"folder_id": "string",
|
||||
"desc": "string",
|
||||
"embedding": "string",
|
||||
"source_url": "string",
|
||||
"selector": "string"
|
||||
}
|
||||
*/
|
||||
const postWebKnowledge: (data: any, loading?: Ref<boolean>) => Promise<Result<any>> = (
|
||||
data,
|
||||
loading,
|
||||
) => {
|
||||
return post(`${prefix}/web`, data, undefined, loading)
|
||||
}
|
||||
|
||||
// 创建飞书知识库
|
||||
const postLarkKnowledge: (data: any, loading?: Ref<boolean>) => Promise<Result<Array<any>>> = (
|
||||
data,
|
||||
loading,
|
||||
) => {
|
||||
return post(`${prefix}/lark/save`, data, null, loading)
|
||||
}
|
||||
|
||||
const putLarkKnowledge: (
|
||||
knowledge_id: string,
|
||||
data: any,
|
||||
|
|
@ -262,10 +219,7 @@ export default {
|
|||
putGenerateRelated,
|
||||
putKnowledgeHitTest,
|
||||
putSyncWebKnowledge,
|
||||
postKnowledge,
|
||||
getKnowledgeModel,
|
||||
postWebKnowledge,
|
||||
postLarkKnowledge,
|
||||
putLarkKnowledge
|
||||
} as {
|
||||
[key: string]: any
|
||||
|
|
|
|||
|
|
@ -111,5 +111,6 @@ export default {
|
|||
},
|
||||
resource_management: {
|
||||
label: 'Resource Management',
|
||||
type: 'Type',
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -111,5 +111,6 @@ export default {
|
|||
},
|
||||
resource_management: {
|
||||
label: '资源管理',
|
||||
},
|
||||
type: '类型',
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,5 +113,6 @@ export default {
|
|||
|
||||
resource_management: {
|
||||
label: '资源管理',
|
||||
type: '类型',
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const systemRouter = {
|
|||
activeMenu: '/system',
|
||||
parentPath: '/system',
|
||||
parentName: 'system',
|
||||
sameRoute: 'user',
|
||||
sameRoute: 'user',
|
||||
permission: [RoleConst.ADMIN, PermissionConst.USER_READ],
|
||||
},
|
||||
component: () => import('@/views/system/user-manage/index.vue'),
|
||||
|
|
@ -33,7 +33,7 @@ const systemRouter = {
|
|||
activeMenu: '/system',
|
||||
parentPath: '/system',
|
||||
parentName: 'system',
|
||||
sameRoute: 'role',
|
||||
sameRoute: 'role',
|
||||
permission: [
|
||||
new ComplexPermission(
|
||||
[RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE.getWorkspaceRole],
|
||||
|
|
@ -55,7 +55,7 @@ const systemRouter = {
|
|||
activeMenu: '/system',
|
||||
parentPath: '/system',
|
||||
parentName: 'system',
|
||||
sameRoute: 'workspace',
|
||||
sameRoute: 'workspace',
|
||||
permission: [
|
||||
new ComplexPermission(
|
||||
[RoleConst.WORKSPACE_MANAGE, RoleConst.ADMIN],
|
||||
|
|
@ -79,6 +79,18 @@ const systemRouter = {
|
|||
parentName: 'system',
|
||||
},
|
||||
children: [
|
||||
// {
|
||||
// path: '/system/resource-management/application',
|
||||
// name: 'ApplicationResourceIndex',
|
||||
// meta: {
|
||||
// title: 'views.application.title',
|
||||
// activeMenu: '/system',
|
||||
// parentPath: '/system',
|
||||
// parentName: 'system',
|
||||
// },
|
||||
// component: () =>
|
||||
// import('@/views/system-resource-management/ApplicationResourceIndex.vue'),
|
||||
// },
|
||||
{
|
||||
path: '/system/resource-management/knowledge',
|
||||
name: 'KnowledgeResourceIndex',
|
||||
|
|
@ -101,17 +113,17 @@ const systemRouter = {
|
|||
},
|
||||
component: () => import('@/views/system-resource-management/ToolResourceIndex.vue'),
|
||||
},
|
||||
{
|
||||
path: '/system/resource-management/model',
|
||||
name: 'ModelResourceIndex',
|
||||
meta: {
|
||||
title: 'views.model.title',
|
||||
activeMenu: '/system',
|
||||
parentPath: '/system',
|
||||
parentName: 'system',
|
||||
},
|
||||
component: () => import('@/views/system-resource-management/ModelResourceIndex.vue'),
|
||||
},
|
||||
// {
|
||||
// path: '/system/resource-management/model',
|
||||
// name: 'ModelResourceIndex',
|
||||
// meta: {
|
||||
// title: 'views.model.title',
|
||||
// activeMenu: '/system',
|
||||
// parentPath: '/system',
|
||||
// parentName: 'system',
|
||||
// },
|
||||
// component: () => import('@/views/system-resource-management/ModelResourceIndex.vue'),
|
||||
// },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
|
@ -124,7 +136,7 @@ const systemRouter = {
|
|||
activeMenu: '/system',
|
||||
parentPath: '/system',
|
||||
parentName: 'system',
|
||||
sameRoute: 'authorization',
|
||||
sameRoute: 'authorization',
|
||||
},
|
||||
component: () => import('@/views/system/resource-authorization/index.vue'),
|
||||
},
|
||||
|
|
@ -210,7 +222,7 @@ const systemRouter = {
|
|||
activeMenu: '/system',
|
||||
parentPath: '/system',
|
||||
parentName: 'system',
|
||||
sameRoute: 'chat',
|
||||
sameRoute: 'chat',
|
||||
permission: [
|
||||
new ComplexPermission(
|
||||
[RoleConst.WORKSPACE_MANAGE, RoleConst.ADMIN],
|
||||
|
|
@ -290,7 +302,7 @@ const systemRouter = {
|
|||
activeMenu: '/system',
|
||||
parentPath: '/system',
|
||||
parentName: 'system',
|
||||
sameRoute: 'setting',
|
||||
sameRoute: 'setting',
|
||||
},
|
||||
children: [
|
||||
{
|
||||
|
|
@ -340,7 +352,7 @@ const systemRouter = {
|
|||
activeMenu: '/system',
|
||||
parentPath: '/system',
|
||||
parentName: 'system',
|
||||
sameRoute: 'operate',
|
||||
sameRoute: 'operate',
|
||||
permission: [EditionConst.IS_PE, EditionConst.IS_EE],
|
||||
},
|
||||
component: () => import('@/views/system/operate-log/index.vue'),
|
||||
|
|
|
|||
|
|
@ -0,0 +1,222 @@
|
|||
<template>
|
||||
<div class="p-16-24">
|
||||
<el-breadcrumb separator-icon="ArrowRight">
|
||||
<el-breadcrumb-item>{{ t('views.system.resource_management.label') }}</el-breadcrumb-item>
|
||||
<el-breadcrumb-item>
|
||||
<h5 class="ml-4 color-text-primary">{{ t('views.application.title') }}</h5>
|
||||
</el-breadcrumb-item>
|
||||
</el-breadcrumb>
|
||||
<el-card class="mt-16">
|
||||
<div class="flex-between mb-16">
|
||||
<div class="complex-search">
|
||||
<el-select
|
||||
class="complex-search__left"
|
||||
v-model="search_type"
|
||||
style="width: 120px"
|
||||
@change="search_type_change"
|
||||
>
|
||||
<el-option :label="$t('common.creator')" value="create_user" />
|
||||
|
||||
<el-option :label="$t('common.name')" value="name" />
|
||||
</el-select>
|
||||
<el-input
|
||||
v-if="search_type === 'name'"
|
||||
v-model="search_form.name"
|
||||
@change="getList"
|
||||
:placeholder="$t('common.searchBar.placeholder')"
|
||||
style="width: 220px"
|
||||
clearable
|
||||
/>
|
||||
<el-select
|
||||
v-else-if="search_type === 'create_user'"
|
||||
v-model="search_form.create_user"
|
||||
@change="getList"
|
||||
clearable
|
||||
style="width: 220px"
|
||||
>
|
||||
<el-option v-for="u in user_options" :key="u.id" :value="u.id" :label="u.username" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<app-table
|
||||
:data="knowledgeList"
|
||||
:pagination-config="paginationConfig"
|
||||
@sizeChange="getList"
|
||||
@changePage="getList"
|
||||
>
|
||||
<!-- <el-table-column type="selection" width="55" /> -->
|
||||
<el-table-column width="220" :label="$t('common.name')">
|
||||
<template #default="scope">
|
||||
<div class="table-name flex align-center">
|
||||
<el-icon size="24" class="mr-8">
|
||||
<el-avatar
|
||||
v-if="isAppIcon(scope.row?.icon)"
|
||||
shape="square"
|
||||
:size="24"
|
||||
style="background: none"
|
||||
class="mr-8"
|
||||
>
|
||||
<img :src="scope.row?.icon" alt="" />
|
||||
</el-avatar>
|
||||
<el-avatar v-else class="avatar-green" shape="square" :size="24">
|
||||
<img src="@/assets/node/icon_tool.svg" style="width: 58%" alt="" />
|
||||
</el-avatar>
|
||||
</el-icon>
|
||||
{{ scope.row.name }}
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
prop="tool_type"
|
||||
:label="$t('views.system.resource_management.type')"
|
||||
width="110"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.type === 1">{{
|
||||
$t('views.knowledge.knowledgeType.webKnowledge')
|
||||
}}</span>
|
||||
<span v-else-if="row.type === 2">{{
|
||||
$t('views.knowledge.knowledgeType.larkKnowledge')
|
||||
}}</span>
|
||||
<span v-else>{{ $t('views.knowledge.knowledgeType.generalKnowledge') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-if="user.isEE()"
|
||||
width="150"
|
||||
prop="workspace_name"
|
||||
:label="$t('views.workspace.title')"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #header>
|
||||
<div>
|
||||
<span>{{ $t('views.workspace.title') }}</span>
|
||||
<el-popover :width="200" trigger="click" :visible="workspaceVisible">
|
||||
<template #reference>
|
||||
<el-button
|
||||
style="margin-top: -2px"
|
||||
:type="workspaceArr && workspaceArr.length > 0 ? 'primary' : ''"
|
||||
link
|
||||
@click="workspaceVisible = !workspaceVisible"
|
||||
>
|
||||
<el-icon>
|
||||
<Filter />
|
||||
</el-icon>
|
||||
</el-button>
|
||||
</template>
|
||||
<div class="filter">
|
||||
<div class="form-item mb-16">
|
||||
<div @click.stop>
|
||||
<el-scrollbar height="300" style="margin: 0 0 0 10px">
|
||||
<el-checkbox-group
|
||||
v-model="workspaceArr"
|
||||
style="display: flex; flex-direction: column"
|
||||
>
|
||||
<el-checkbox
|
||||
v-for="item in workspaceOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-checkbox-group>
|
||||
</el-scrollbar>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<el-button size="small" @click="filterWorkspaceChange('clear')"
|
||||
>{{ $t('common.clear') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="filterWorkspaceChange" size="small"
|
||||
>{{ $t('common.confirm') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-popover>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="nick_name" :label="$t('common.creator')" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('views.document.table.updateTime')" width="180">
|
||||
<template #default="{ row }">
|
||||
{{ datetimeFormat(row.update_time) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('common.createTime')" width="180">
|
||||
<template #default="{ row }">
|
||||
{{ datetimeFormat(row.create_time) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</app-table>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, ref, reactive, computed } from 'vue'
|
||||
import { cloneDeep, get } from 'lodash'
|
||||
import KnowledgeResourceApi from '@/api/system-resource-management/knowledge'
|
||||
import { t } from '@/locales'
|
||||
import { isAppIcon } from '@/utils/common'
|
||||
import useStore from '@/stores'
|
||||
import WorkspaceApi from '@/api/workspace/workspace.ts'
|
||||
import { datetimeFormat } from '@/utils/time'
|
||||
|
||||
const { user } = useStore()
|
||||
|
||||
const search_type = ref('name')
|
||||
const search_form = ref<any>({
|
||||
name: '',
|
||||
create_user: '',
|
||||
})
|
||||
const user_options = ref<any[]>([])
|
||||
|
||||
const loading = ref(false)
|
||||
const changeStateloading = ref(false)
|
||||
const knowledgeList = ref<any[]>([])
|
||||
const paginationConfig = reactive({
|
||||
current_page: 1,
|
||||
page_size: 30,
|
||||
total: 0,
|
||||
})
|
||||
const workspaceOptions = ref<any[]>([])
|
||||
const workspaceVisible = ref(false)
|
||||
const workspaceArr = ref<any[]>([])
|
||||
function filterWorkspaceChange(val: string) {
|
||||
if (val === 'clear') {
|
||||
workspaceArr.value = []
|
||||
}
|
||||
getList()
|
||||
workspaceVisible.value = false
|
||||
}
|
||||
async function getWorkspaceList() {
|
||||
if (user.isEE()) {
|
||||
const res = await WorkspaceApi.getSystemWorkspaceList(loading)
|
||||
workspaceOptions.value = res.data.map((item: any) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}))
|
||||
}
|
||||
}
|
||||
const search_type_change = () => {
|
||||
search_form.value = { name: '', create_user: '' }
|
||||
}
|
||||
|
||||
function getList() {
|
||||
const params = {
|
||||
[search_type.value]: search_form.value[search_type.value],
|
||||
}
|
||||
KnowledgeResourceApi.getKnowledgeListPage(paginationConfig, params, loading).then((res: any) => {
|
||||
paginationConfig.total = res.data?.total
|
||||
knowledgeList.value = res.data?.records
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getWorkspaceList()
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
@ -68,19 +68,19 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="tool_type" :label="$t('views.application.form.appType.label')">
|
||||
<template #default="scope">
|
||||
{{ $t(ToolType[scope.row.tool_type as keyof typeof ToolType]) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('common.status.label')" width="120">
|
||||
<template #default="scope">
|
||||
<div class="flex align-center">
|
||||
<AppIcon
|
||||
:iconName="scope.row.is_active ? 'app-close_colorful' : 'app-succeed'"
|
||||
></AppIcon>
|
||||
{{ $t(scope.row.is_active ? 'views.tool.enabled' : 'common.status.disable') }}
|
||||
</div>
|
||||
<el-table-column
|
||||
prop="tool_type"
|
||||
:label="$t('views.system.resource_management.type')"
|
||||
width="110"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.type === 1">{{
|
||||
$t('views.knowledge.knowledgeType.webKnowledge')
|
||||
}}</span>
|
||||
<span v-else-if="row.type === 2">{{
|
||||
$t('views.knowledge.knowledgeType.larkKnowledge')
|
||||
}}</span>
|
||||
<span v-else>{{ $t('views.knowledge.knowledgeType.generalKnowledge') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
|
|
@ -219,7 +219,4 @@ onMounted(() => {
|
|||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.resource-manage_tool {
|
||||
}
|
||||
</style>
|
||||
<style lang="scss" scoped></style>
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="tool_type" :label="$t('views.application.form.appType.label')">
|
||||
<el-table-column prop="tool_type" :label="$t('views.system.resource_management.type')">
|
||||
<template #default="scope">
|
||||
{{ $t(ToolType[scope.row.tool_type as keyof typeof ToolType]) }}
|
||||
</template>
|
||||
|
|
@ -234,7 +234,7 @@ const list_model = () => {
|
|||
|
||||
onMounted(() => {
|
||||
getWorkspaceList()
|
||||
list_model()
|
||||
// list_model()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="tool_type" :label="$t('views.application.form.appType.label')">
|
||||
<el-table-column prop="tool_type" :label="$t('views.system.resource_management.type')">
|
||||
<template #default="scope">
|
||||
{{ $t(ToolType[scope.row.tool_type as keyof typeof ToolType]) }}
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Reference in New Issue