mirror of
https://github.com/1Panel-dev/MaxKB.git
synced 2025-12-30 17:52:48 +00:00
49 lines
1.1 KiB
TypeScript
49 lines
1.1 KiB
TypeScript
import { defineStore } from 'pinia'
|
|
import paragraphApi from '@/api/paragraph'
|
|
import type { Ref } from 'vue'
|
|
|
|
const useParagraphStore = defineStore({
|
|
id: 'paragraph',
|
|
state: () => ({}),
|
|
actions: {
|
|
async asyncPutParagraph(
|
|
datasetId: string,
|
|
documentId: string,
|
|
paragraphId: string,
|
|
data: any,
|
|
loading?: Ref<boolean>
|
|
) {
|
|
return new Promise((resolve, reject) => {
|
|
paragraphApi
|
|
.putParagraph(datasetId, documentId, paragraphId, data, loading)
|
|
.then((data) => {
|
|
resolve(data)
|
|
})
|
|
.catch((error) => {
|
|
reject(error)
|
|
})
|
|
})
|
|
},
|
|
|
|
async asyncDelParagraph(
|
|
datasetId: string,
|
|
documentId: string,
|
|
paragraphId: string,
|
|
loading?: Ref<boolean>
|
|
) {
|
|
return new Promise((resolve, reject) => {
|
|
paragraphApi
|
|
.delParagraph(datasetId, documentId, paragraphId, loading)
|
|
.then((data) => {
|
|
resolve(data)
|
|
})
|
|
.catch((error) => {
|
|
reject(error)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
|
|
export default useParagraphStore
|