feat: shared
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run

This commit is contained in:
wangdan-fit2cloud 2025-06-25 11:19:35 +08:00
parent 2364bd275a
commit 12e8242365
13 changed files with 61 additions and 45 deletions

View File

@ -6,6 +6,22 @@ import type { pageRequest } from '@/api/type/common'
const prefix = '/system/shared/knowledge'
/**
*
* @param knowledge_id,
* param {
" name": "string",
}
*/
const getDocumentList: (knowledge_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
knowledge_id,
loading,
) => {
return get(`${prefix}/${knowledge_id}/document`, undefined, loading)
}
/**
*
* @param knowledge_id,
@ -506,14 +522,9 @@ const importLarkDocument: (
return post(`${prefix}/lark/${knowledge_id}/import`, data, null, loading)
}
const getAllDocument: (knowledge_id: string, loading?: Ref<boolean>) => Promise<Result<any>> = (
knowledge_id,
loading,
) => {
return get(`${prefix}/${knowledge_id}/document`, undefined, loading)
}
export default {
getDocumentList,
getDocumentPage,
getDocumentDetail,
putDocument,

View File

@ -1,19 +1,24 @@
import {defineStore} from 'pinia'
import {type Ref} from 'vue'
import ModelApi from '@/api/model/model'
import { defineStore } from 'pinia'
import { type Ref } from 'vue'
import ProviderApi from '@/api/model/provider'
import type {ListModelRequest} from '@/api/type/model'
import type { ListModelRequest } from '@/api/type/model'
import { loadSharedApi } from '@/utils/dynamics-api/shared-api'
const useModelStore = defineStore('model', {
state: () => ({}),
actions: {
async asyncGetModel(data?: ListModelRequest, loading?: Ref<boolean>) {
async asyncGetModel(
data?: ListModelRequest,
systemType: 'systemShare' | 'workspace' | 'systemManage' = 'workspace',
loading?: Ref<boolean>,
) {
return new Promise((resolve, reject) => {
ModelApi.getModel(data, loading)
.then((res) => {
loadSharedApi({ type: 'model', systemType })
.getModel(data, loading)
.then((res: any) => {
resolve(res)
})
.catch((error) => {
.catch((error: any) => {
reject(error)
})
})

View File

@ -50,8 +50,8 @@ const useParagraphStore = defineStore('paragraph', {
) {
return new Promise((resolve, reject) => {
const obj = {
paragraphId,
problemId,
paragraph_id: paragraphId,
problem_id: problemId,
}
paragraphApi
.putDisassociationProblem(knowledgeId, documentId, obj, loading)
@ -72,8 +72,8 @@ const useParagraphStore = defineStore('paragraph', {
) {
return new Promise((resolve, reject) => {
const obj = {
paragraphId,
problemId,
paragraph_id: paragraphId,
problem_id: problemId,
}
paragraphApi
.putAssociationProblem(knowledgeId, documentId, obj, loading)

View File

@ -217,7 +217,7 @@ function changeDocument(document_id: string) {
}
function getDocument(knowledge_id: string) {
document.asyncGetAllDocument(knowledge_id, loading).then((res: any) => {
document.asyncGetKnowledgeDocument(knowledge_id, loading).then((res: any) => {
documentList.value = res.data
if (localStorage.getItem(id + 'chat_document_id')) {
form.value.document_id = localStorage.getItem(id + 'chat_document_id') as string

View File

@ -569,7 +569,7 @@ function saveCleanTime() {
function changeKnowledge(knowledge_id: string) {
localStorage.setItem(id + 'chat_knowledge_id', knowledge_id)
form.value.document_id = ''
getDocumentPage(knowledge_id)
getDocument(knowledge_id)
}
function changeDocument(document_id: string) {
@ -617,7 +617,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
}
function getDocument(knowledge_id: string) {
document.asyncGetAllDocument(knowledge_id, documentLoading).then((res: any) => {
document.asyncGetKnowledgeDocument(knowledge_id, documentLoading).then((res: any) => {
documentList.value = res.data
if (localStorage.getItem(id + 'chat_document_id')) {
form.value.document_id = localStorage.getItem(id + 'chat_document_id') as string

View File

@ -8,7 +8,7 @@
<h4 class="title-decoration-1 mb-16">
{{ $t('common.info') }}
</h4>
<BaseForm ref="BaseFormRef" :data="detail" />
<BaseForm ref="BaseFormRef" :data="detail" :apiType="apiType" />
<el-form
ref="webFormRef"

View File

@ -42,20 +42,20 @@
</el-form>
</template>
<script setup lang="ts">
import {ref, reactive, onMounted, onUnmounted, computed, watch} from 'vue'
import {groupBy} from 'lodash'
import { ref, reactive, onMounted, onUnmounted, computed, watch } from 'vue'
import { groupBy } from 'lodash'
import useStore from '@/stores'
import type {knowledgeData} from '@/api/type/knowledge'
import {t} from '@/locales'
import type { knowledgeData } from '@/api/type/knowledge'
import { t } from '@/locales'
const props = defineProps({
const props = defineProps<{
data: {
type: Object,
default: () => {
},
},
})
const {model} = useStore()
type: Object
default: () => {}
}
apiType: 'systemShare' | 'workspace' | 'systemManage'
}>()
const { model } = useStore()
const form = ref<knowledgeData>({
name: '',
desc: '',
@ -92,7 +92,7 @@ const modelOptions = ref<any>([])
watch(
() => props.data,
(value) => {
(value: any) => {
if (value && JSON.stringify(value) !== '{}') {
form.value.name = value.name
form.value.desc = value.desc
@ -117,7 +117,7 @@ function validate() {
function getModel() {
loading.value = true
model
.asyncGetModel({model_type: 'EMBEDDING'})
.asyncGetModel({ model_type: 'EMBEDDING' }, props.apiType)
.then((res: any) => {
modelOptions.value = groupBy(res?.data, 'provider')
loading.value = false

View File

@ -8,7 +8,7 @@
:close-on-press-escape="false"
>
<!-- 基本信息 -->
<BaseForm ref="BaseFormRef" v-if="dialogVisible" />
<BaseForm ref="BaseFormRef" v-if="dialogVisible" :apiType="apiType" />
<template #footer>
<span class="dialog-footer">

View File

@ -8,7 +8,7 @@
:close-on-press-escape="false"
>
<!-- 基本信息 -->
<BaseForm ref="BaseFormRef" v-if="dialogVisible" />
<BaseForm ref="BaseFormRef" v-if="dialogVisible" :apiType="apiType" />
<el-form
ref="knowledgeFormRef"
:rules="rules"

View File

@ -8,7 +8,7 @@
:close-on-press-escape="false"
>
<!-- 基本信息 -->
<BaseForm ref="BaseFormRef" v-if="dialogVisible" />
<BaseForm ref="BaseFormRef" v-if="dialogVisible" :apiType="apiType" />
<el-form
ref="KnowledgeFormRef"
:rules="rules"

View File

@ -146,13 +146,13 @@ const props = defineProps<{
updateModelById: (model_id: string, model: Model) => void
isShared?: boolean | undefined
isSystemShare?: boolean | undefined
sharedType: 'systemShare' | 'workspace' | 'systemManage'
apiType: 'systemShare' | 'workspace' | 'systemManage'
}>()
const { user } = useStore()
const permissionPrecise = computed(() => {
return permissionMap['model'][props.sharedType]
return permissionMap['model'][props.apiType]
})
const downModel = ref<Model>()
@ -188,7 +188,7 @@ const deleteModel = () => {
},
)
.then(() => {
loadSharedApi({ type: 'model', systemType: props.sharedType })
loadSharedApi({ type: 'model', systemType: props.apiType })
.deleteModel(props.model.id)
.then(() => {
emit('change')
@ -198,7 +198,7 @@ const deleteModel = () => {
}
const cancelDownload = () => {
loadSharedApi({ type: 'model', systemType: props.sharedType })
loadSharedApi({ type: 'model', systemType: props.apiType })
.pauseDownload(props.model.id)
.then(() => {
downModel.value = undefined
@ -221,7 +221,7 @@ const icon = computed(() => {
const initInterval = () => {
interval = setInterval(() => {
if (currentModel.value.status === 'DOWNLOAD') {
loadSharedApi({ type: 'model', systemType: props.sharedType })
loadSharedApi({ type: 'model', systemType: props.apiType })
.getModelMetaById(props.model.id)
.then((ok: any) => {
downModel.value = ok.data

View File

@ -88,7 +88,7 @@
:provider_list="provider_list"
:isShared="isShared"
:isSystemShare="isSystemShare"
:sharedType="apiType"
:apiType="apiType"
>
</ModelCard>
</el-col>

View File

@ -214,7 +214,7 @@ function clickDocumentHandle(item: any) {
}
function getDocument() {
document.asyncGetAllDocument(id, loading).then((res: any) => {
document.asyncGetKnowledgeDocument(id, loading).then((res: any) => {
cloneDocumentList.value = res.data
documentList.value = res.data
currentDocument.value = cloneDocumentList.value?.length > 0 ? cloneDocumentList.value[0].id : ''