diff options
author | Zero~Informatique | 2019-12-21 02:06:02 +0100 |
---|---|---|
committer | Zero~Informatique | 2019-12-21 02:06:02 +0100 |
commit | 62005141132da1e9761598fa3e4b35b4dab38a89 (patch) | |
tree | 3ff8b9f3acd07801075202f9eb2d2f2dfd328ff5 /viewer/src | |
parent | bdce958eddc527912a57afa5b8151e1a90e38355 (diff) | |
download | ldgallery-62005141132da1e9761598fa3e4b35b4dab38a89.tar.gz |
Implemented VueX and a basic UIStore with the fullscreen mutation
Some renaming
Diffstat (limited to 'viewer/src')
-rw-r--r-- | viewer/src/main.ts | 4 | ||||
-rw-r--r-- | viewer/src/plugins/fontawesome.ts (renamed from viewer/src/plugins/fontawesome.js) | 0 | ||||
-rw-r--r-- | viewer/src/plugins/vuex.ts | 23 | ||||
-rw-r--r-- | viewer/src/store/uiStore.ts | 15 | ||||
-rw-r--r-- | viewer/src/views/LdGallery.vue | 16 |
5 files changed, 48 insertions, 10 deletions
diff --git a/viewer/src/main.ts b/viewer/src/main.ts index 352b565..3a3593c 100644 --- a/viewer/src/main.ts +++ b/viewer/src/main.ts | |||
@@ -2,6 +2,7 @@ import Vue from "vue"; | |||
2 | import "@/assets/scss/global.scss"; | 2 | import "@/assets/scss/global.scss"; |
3 | import "@/plugins/fontawesome"; | 3 | import "@/plugins/fontawesome"; |
4 | import "@/plugins/buefy"; | 4 | import "@/plugins/buefy"; |
5 | import store from '@/plugins/vuex' | ||
5 | import i18n from "@/plugins/i18n"; | 6 | import i18n from "@/plugins/i18n"; |
6 | import router from "@/router"; | 7 | import router from "@/router"; |
7 | import LdGallery from "@/views/LdGallery.vue"; | 8 | import LdGallery from "@/views/LdGallery.vue"; |
@@ -11,5 +12,6 @@ Vue.config.productionTip = false; | |||
11 | new Vue({ | 12 | new Vue({ |
12 | router, | 13 | router, |
13 | i18n, | 14 | i18n, |
14 | render: h => h(LdGallery), | 15 | store, |
16 | render: h => h(LdGallery) | ||
15 | }).$mount("#ldgallery"); | 17 | }).$mount("#ldgallery"); |
diff --git a/viewer/src/plugins/fontawesome.js b/viewer/src/plugins/fontawesome.ts index 9bf4dba..9bf4dba 100644 --- a/viewer/src/plugins/fontawesome.js +++ b/viewer/src/plugins/fontawesome.ts | |||
diff --git a/viewer/src/plugins/vuex.ts b/viewer/src/plugins/vuex.ts new file mode 100644 index 0000000..9b2fa46 --- /dev/null +++ b/viewer/src/plugins/vuex.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import Vue from 'vue' | ||
2 | import Vuex from 'vuex' | ||
3 | import { extractVuexModule } from "vuex-class-component"; | ||
4 | import { createProxy } from "vuex-class-component"; | ||
5 | import UIStore from '@/store/uiStore'; | ||
6 | |||
7 | Vue.use(Vuex) | ||
8 | |||
9 | const store = new Vuex.Store({ | ||
10 | modules: { | ||
11 | ...extractVuexModule(UIStore) | ||
12 | } | ||
13 | }); | ||
14 | |||
15 | Vue.use((vue) => vue.prototype.$uiStore = createProxy(store, UIStore)); | ||
16 | |||
17 | declare module 'vue/types/vue' { | ||
18 | interface Vue { | ||
19 | $uiStore: UIStore | ||
20 | } | ||
21 | } | ||
22 | |||
23 | export default store; | ||
diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts new file mode 100644 index 0000000..c4143a1 --- /dev/null +++ b/viewer/src/store/uiStore.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import { createModule, mutation, action } from "vuex-class-component"; | ||
2 | |||
3 | const VuexModule = createModule({ | ||
4 | namespaced: "uiStore", | ||
5 | strict: true | ||
6 | }) | ||
7 | |||
8 | export default class UIStore extends VuexModule { | ||
9 | |||
10 | fullscreen: boolean = false; | ||
11 | |||
12 | @mutation toggleFullscreen() { | ||
13 | this.fullscreen = !this.fullscreen; | ||
14 | } | ||
15 | } | ||
diff --git a/viewer/src/views/LdGallery.vue b/viewer/src/views/LdGallery.vue index 98f083f..d22bfa6 100644 --- a/viewer/src/views/LdGallery.vue +++ b/viewer/src/views/LdGallery.vue | |||
@@ -1,9 +1,13 @@ | |||
1 | <template> | 1 | <template> |
2 | <div :class="{fullscreen}"> | 2 | <div :class="{fullscreen: $uiStore.fullscreen}"> |
3 | <div class="layout top">header</div> | 3 | <div class="layout top">header</div> |
4 | <div class="layout left">panel</div> | 4 | <div class="layout left">panel</div> |
5 | <router-view class="layout content" /> | 5 | <router-view class="layout content" /> |
6 | <fa-icon icon="expand-arrows-alt" class="layout button-fullscreen" @click="toggleFullscreen" /> | 6 | <fa-icon |
7 | icon="expand-arrows-alt" | ||
8 | class="layout button-fullscreen" | ||
9 | @click="$uiStore.toggleFullscreen()" | ||
10 | /> | ||
7 | </div> | 11 | </div> |
8 | </template> | 12 | </template> |
9 | 13 | ||
@@ -11,13 +15,7 @@ | |||
11 | import { Component, Vue } from "vue-property-decorator"; | 15 | import { Component, Vue } from "vue-property-decorator"; |
12 | 16 | ||
13 | @Component | 17 | @Component |
14 | export default class LdGallery extends Vue { | 18 | export default class LdGallery extends Vue {} |
15 | fullscreen: boolean = false; | ||
16 | |||
17 | toggleFullscreen() { | ||
18 | this.fullscreen = !this.fullscreen; | ||
19 | } | ||
20 | } | ||
21 | </script> | 19 | </script> |
22 | 20 | ||
23 | <style lang="scss"> | 21 | <style lang="scss"> |