init
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref } from 'vue'
|
||||
import { generateApi } from '@/api/generate'
|
||||
import type { Document } from '@/types'
|
||||
|
||||
export const useDocumentStore = defineStore('document', () => {
|
||||
const documents = ref<Document[]>([])
|
||||
const currentDoc = ref<Document | null>(null)
|
||||
const loading = ref(false)
|
||||
|
||||
async function fetchList(params?: any) { loading.value = true; try { const r: any = await generateApi.documents(params); documents.value = r.data?.items || r.data || [] } finally { loading.value = false } }
|
||||
async function generateFull(data: any) { const r: any = await generateApi.full(data); return r.data }
|
||||
async function cancel(id: number) { await generateApi.cancel(id) }
|
||||
async function removeDoc(id: number) { await generateApi.deleteDocument(id); await fetchList() }
|
||||
|
||||
return { documents, currentDoc, loading, fetchList, generateFull, cancel, removeDoc }
|
||||
})
|
||||
Reference in New Issue
Block a user