feat: shared

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' 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, * @param knowledge_id,
@ -506,14 +522,9 @@ const importLarkDocument: (
return post(`${prefix}/lark/${knowledge_id}/import`, data, null, loading) 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 { export default {
getDocumentList,
getDocumentPage, getDocumentPage,
getDocumentDetail, getDocumentDetail,
putDocument, putDocument,

View File

@ -1,19 +1,24 @@
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { type Ref } from 'vue' import { type Ref } from 'vue'
import ModelApi from '@/api/model/model'
import ProviderApi from '@/api/model/provider' 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', { const useModelStore = defineStore('model', {
state: () => ({}), state: () => ({}),
actions: { 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) => { return new Promise((resolve, reject) => {
ModelApi.getModel(data, loading) loadSharedApi({ type: 'model', systemType })
.then((res) => { .getModel(data, loading)
.then((res: any) => {
resolve(res) resolve(res)
}) })
.catch((error) => { .catch((error: any) => {
reject(error) reject(error)
}) })
}) })

View File

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

View File

@ -217,7 +217,7 @@ function changeDocument(document_id: string) {
} }
function getDocument(knowledge_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 documentList.value = res.data
if (localStorage.getItem(id + 'chat_document_id')) { if (localStorage.getItem(id + 'chat_document_id')) {
form.value.document_id = localStorage.getItem(id + 'chat_document_id') as string 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) { function changeKnowledge(knowledge_id: string) {
localStorage.setItem(id + 'chat_knowledge_id', knowledge_id) localStorage.setItem(id + 'chat_knowledge_id', knowledge_id)
form.value.document_id = '' form.value.document_id = ''
getDocumentPage(knowledge_id) getDocument(knowledge_id)
} }
function changeDocument(document_id: string) { function changeDocument(document_id: string) {
@ -617,7 +617,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
} }
function getDocument(knowledge_id: string) { 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 documentList.value = res.data
if (localStorage.getItem(id + 'chat_document_id')) { if (localStorage.getItem(id + 'chat_document_id')) {
form.value.document_id = localStorage.getItem(id + 'chat_document_id') as string 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"> <h4 class="title-decoration-1 mb-16">
{{ $t('common.info') }} {{ $t('common.info') }}
</h4> </h4>
<BaseForm ref="BaseFormRef" :data="detail" /> <BaseForm ref="BaseFormRef" :data="detail" :apiType="apiType" />
<el-form <el-form
ref="webFormRef" ref="webFormRef"

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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