before store

This commit is contained in:
2025-06-26 11:06:48 +03:00
parent 1c732e16dd
commit 34baeb40e3
59 changed files with 3180 additions and 2149 deletions

View File

@@ -2,19 +2,19 @@ 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'
import type { FileLink } from 'types/FileLink'
export const useFilesStore = defineStore('files', () => {
const files = ref<File[]>([])
const files = ref<FileLink[]>([])
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
const { data } = await api.get('/project/' + currentProjectId.value + '/file')
const filesAPI = data.data
files.value.push(...filesAPI)
isInit.value = true
}
@@ -34,6 +34,7 @@ export const useFilesStore = defineStore('files', () => {
return (await response).data.data
}
const getFiles = computed(() => files.value)
function fileById (id: number) {
return files.value.find(el =>el.id === id)
@@ -46,6 +47,7 @@ export const useFilesStore = defineStore('files', () => {
reset,
fileUrl,
remove,
getFiles,
fileById
}
})