21 lines
740 B
TypeScript
21 lines
740 B
TypeScript
interface imagesList {
|
|
[key: string]: {
|
|
status: 'idle' | 'pending' | 'success' | 'error',
|
|
result?: string
|
|
}
|
|
}
|
|
export const useImagesStore = defineStore('images', {
|
|
state: () => ({ list: {} as imagesList }),
|
|
actions: {
|
|
getImage(name: string) {
|
|
if (this.list[name]) {
|
|
return this.list[name].result
|
|
} else {
|
|
this.list[name] = {
|
|
status: 'idle',
|
|
result: 'https://media.istockphoto.com/id/1490517357/photo/scientists-are-researching-and-analyzing-harmful-contaminants-in-the-laboratory.webp?s=170667a&w=0&k=20&c=Fh4t-P_b-a1QxwyBUzUa0AuLp8FLNyLy4hl4HUm82Ao='
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}) |