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([]) const currentDoc = ref(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 } })