diff options
author | Zero~Informatique | 2019-12-21 08:08:54 +0100 |
---|---|---|
committer | Zero~Informatique | 2019-12-21 08:08:54 +0100 |
commit | 9e4fdd6f38853d8a4a959901ab7902569de75484 (patch) | |
tree | 3255e7fc08a6767ce8c333a42388f6398d2b460e /viewer/src/store/galleryStore.ts | |
parent | 40e8303d6b37a062754fdfbe824a153b8e5e2ddf (diff) | |
download | ldgallery-9e4fdd6f38853d8a4a959901ab7902569de75484.tar.gz |
viewer:
Implemented the "example" project in devServer
Display loader and error messages (not translated yet)
Created a "GalleryStore" to fetch the JSon data from the gallery (currently from example)
Diffstat (limited to 'viewer/src/store/galleryStore.ts')
-rw-r--r-- | viewer/src/store/galleryStore.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts new file mode 100644 index 0000000..63e5109 --- /dev/null +++ b/viewer/src/store/galleryStore.ts | |||
@@ -0,0 +1,21 @@ | |||
1 | import { createModule, mutation, action } from "vuex-class-component"; | ||
2 | |||
3 | const VuexModule = createModule({ | ||
4 | namespaced: "galleryStore", | ||
5 | strict: true | ||
6 | }) | ||
7 | |||
8 | export default class GalleryStore extends VuexModule { | ||
9 | |||
10 | galleryItems: Gallery.Item[] = []; | ||
11 | |||
12 | @mutation setGalleryItems(galleryItems: Gallery.Item[]) { | ||
13 | this.galleryItems = galleryItems; | ||
14 | } | ||
15 | |||
16 | @action async fetchGalleryItems(url: string) { | ||
17 | fetch(url) | ||
18 | .then(response => response.json()) | ||
19 | .then(this.setGalleryItems); | ||
20 | } | ||
21 | } \ No newline at end of file | ||