first 3D model
All checks were successful
Deploy App / deploy (push) Successful in 1m18s

This commit is contained in:
valere
2025-09-17 23:39:43 +02:00
parent 116d15d1ce
commit 0c1cf30996
28 changed files with 1384 additions and 63 deletions

51
app/store/dataStore.ts Normal file
View File

@@ -0,0 +1,51 @@
import type { Compilation, Artist, Track } from '~/../types/types'
// stores/data.ts
import { defineStore } from 'pinia'
export const useDataStore = defineStore('data', {
state: () => ({
compilations: [] as Compilation[], // Store your compilation data here
artists: [] as Artist[], // Store artist data here
tracks: [] as Track[], // Store track data here
isLoaded: false, // Remember if data is already loaded
}),
actions: {
async loadData() {
if (this.isLoaded) return // Avoid re-fetching if already loaded
// Fetch your data once (e.g., from an API or local JSON)
const { data: compilations } = await useFetch('/api/compilations')
const { data: artists } = await useFetch('/api/artists')
const { data: tracks } = await useFetch('/api/tracks')
// Set the data in the store
this.compilations = compilations.value
this.artists = artists.value
this.tracks = tracks.value
this.isLoaded = true
}
},
getters: {
// Obtenir tous les compilations
getAllCompilations: (state) => state.compilations,
getCompilationById: (state) => {
return (id: string) => {
return state.compilations.find(compilation => compilation.id === id)
}
},
// Obtenir toutes les pistes d'une compilation donnée
getTracksByCompilationId: (state) => (compilationId: string) => {
return state.tracks.filter(track => track.compilationId === compilationId)
},
// Filtrer les artistes selon certains critères
getArtistById: (state) => (id: number) => state.artists.find(artist => artist.id === id),
// Obtenir toutes les pistes d'un artiste donné
getTracksByArtistId: (state) => (artistId: string) => {
return state.tracks.filter(track => track.artistId === artistId)
},
},
})