Skip to content

Commit d0ebf04

Browse files
committed
Added store persist and added theme to store
1 parent aaa5640 commit d0ebf04

File tree

5 files changed

+37
-6
lines changed

5 files changed

+37
-6
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "open-gamers-library",
33
"productName": "OGL",
4-
"version": "0.1.4",
4+
"version": "0.1.5",
55
"description": "Open Gamers' Library - Hoard, play and rate your games!",
66
"license": "MIT",
77
"copyright": "Copyright © 2020 Houby Studio",
@@ -27,7 +27,8 @@
2727
"vue": "^2.6.10",
2828
"vue-router": "^3.1.3",
2929
"vuetify": "^2.1.0",
30-
"vuex": "^3.1.2"
30+
"vuex": "^3.1.2",
31+
"vuex-persist": "^2.2.0"
3132
},
3233
"devDependencies": {
3334
"@vue/cli-plugin-babel": "^4.1.0",

src/plugins/vuetify.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import Vue from 'vue'
22
import Vuetify from 'vuetify/lib'
3+
import store from '../store'
34

45
Vue.use(Vuetify)
56

67
export default new Vuetify({
8+
theme: {
9+
dark: store.state.themeDark
10+
}
711
})

src/store/index.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
11
import Vue from 'vue'
22
import Vuex from 'vuex'
3+
import VuexPersistence from 'vuex-persist'
34
import { remote } from 'electron'
45

56
Vue.use(Vuex)
67

8+
const vuexLocal = new VuexPersistence({
9+
storage: window.localStorage
10+
})
11+
712
export default new Vuex.Store({
813
state: {
914
version: remote.app.getVersion(),
1015
footerIsHidden: false,
11-
logoIsHidden: false
16+
logoIsHidden: false,
17+
themeDark: false
1218
},
1319
mutations: {
1420
hideFooter (state) {
1521
state.footerIsHidden = !state.footerIsHidden
1622
},
1723
hideLogo (state) {
1824
state.logoIsHidden = !state.logoIsHidden
25+
},
26+
toggleDarkTheme (state) {
27+
state.themeDark = !state.themeDark
1928
}
2029
},
2130
actions: {
2231
},
2332
modules: {
24-
}
33+
},
34+
plugins: [vuexLocal.plugin]
2535
})

src/views/Settings.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<v-row>
99
<v-col cols="12" md="6">
1010
<span>Scheme</span>
11-
<v-switch v-model="$vuetify.theme.dark" primary label="Dark" />
11+
<v-switch v-model="localtoggleDarkTheme" v-on:change="$vuetify.theme.dark = localtoggleDarkTheme" label="Dark" />
1212
</v-col>
1313
<v-col cols="12" md="6">
1414
<span>Logo</span>
@@ -50,6 +50,14 @@ export default {
5050
set: function () {
5151
this.$store.commit('hideFooter')
5252
}
53+
},
54+
localtoggleDarkTheme: {
55+
get: function () {
56+
return this.$store.state.themeDark
57+
},
58+
set: function () {
59+
this.$store.commit('toggleDarkTheme')
60+
}
5361
}
5462
}
5563
}

yarn.lock

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7296,7 +7296,7 @@ [email protected], lodash.memoize@^4.1.2:
72967296
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
72977297
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=
72987298

7299-
lodash.merge@^4.6.1:
7299+
lodash.merge@^4.6.1, lodash.merge@^4.6.2:
73007300
version "4.6.2"
73017301
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
73027302
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
@@ -11572,6 +11572,14 @@ vuetify@^2.1.0:
1157211572
resolved "https://registry.yarnpkg.com/vuetify/-/vuetify-2.1.15.tgz#26386557c63ad700e6e8d8a330f8d2831fbef6ef"
1157311573
integrity sha512-M35NJvlzkbCpFfsK08xraNvCpiNCIbYUXI/hkzjWHQV1MFIZnjrDTVtYoiudCyJ52zlrhWezAr4pzFOCLAr6RA==
1157411574

11575+
vuex-persist@^2.2.0:
11576+
version "2.2.0"
11577+
resolved "https://registry.yarnpkg.com/vuex-persist/-/vuex-persist-2.2.0.tgz#4acec75562896b045c43d319690b93d6bc1b2bbc"
11578+
integrity sha512-o/qbBeMcKZZqMvCXc7kfIew/5cjHxlP1f53rx5YYp3r2tk2kxXYK/UZumxKn7OXywlurl2r0mgkuBzH6nIWFjw==
11579+
dependencies:
11580+
flatted "^2.0.0"
11581+
lodash.merge "^4.6.2"
11582+
1157511583
vuex@^3.1.2:
1157611584
version "3.1.2"
1157711585
resolved "https://registry.yarnpkg.com/vuex/-/vuex-3.1.2.tgz#a2863f4005aa73f2587e55c3fadf3f01f69c7d4d"

0 commit comments

Comments
 (0)