UnisKB/ui/src/stores/modules/paragraph.ts

49 lines
1.1 KiB
TypeScript
Raw Normal View History

2023-11-14 10:12:55 +00:00
import { defineStore } from 'pinia'
2023-11-22 10:37:08 +00:00
import paragraphApi from '@/api/paragraph'
2023-12-15 03:04:10 +00:00
import type { Ref } from 'vue'
2023-11-14 10:12:55 +00:00
const useParagraphStore = defineStore({
id: 'paragraph',
state: () => ({}),
actions: {
2023-12-15 03:04:10 +00:00
async asyncPutParagraph(
datasetId: string,
documentId: string,
paragraphId: string,
data: any,
loading?: Ref<boolean>
) {
2023-11-14 10:12:55 +00:00
return new Promise((resolve, reject) => {
2023-11-22 10:37:08 +00:00
paragraphApi
2023-12-15 03:04:10 +00:00
.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)
2023-11-14 10:12:55 +00:00
.then((data) => {
resolve(data)
})
.catch((error) => {
reject(error)
})
})
}
}
})
export default useParagraphStore