This commit is contained in:
2025-06-05 20:00:58 +03:00
parent c8f3c9801f
commit 1c732e16dd
203 changed files with 9793 additions and 3960 deletions

51
src/stores/files.ts Normal file
View File

@@ -0,0 +1,51 @@
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import { api } from 'boot/axios'
import { useProjectsStore } from 'stores/projects'
import type { File } from 'types/File'
export const useFilesStore = defineStore('files', () => {
const files = ref<File[]>([])
const isInit = ref<boolean>(false)
const projectsStore = useProjectsStore()
const currentProjectId = computed(() => projectsStore.currentProjectId)
async function init () {
const response = await api.get('/project/' + currentProjectId.value + '/file')
const filesAPI = response.data.data
files.value.push(...filesAPI)
isInit.value = true
}
function reset () {
files.value = []
isInit.value = false
}
async function fileUrl (fileId: number) {
const response = api.get('/project/' + currentProjectId.value + '/file/' + fileId)
return (await response).data.data
}
async function remove (fileId: number) {
const response = api.delete('/project/' + currentProjectId.value + '/file/' + fileId)
return (await response).data.data
}
function fileById (id: number) {
return files.value.find(el =>el.id === id)
}
return {
files,
isInit,
init,
reset,
fileUrl,
remove,
fileById
}
})