add vuex store with 'connected' state

This commit is contained in:
Axolotle 2020-07-10 18:38:59 +02:00
parent 665b661a2b
commit 6fb98f2195
4 changed files with 32 additions and 3 deletions

5
app/package-lock.json generated
View file

@ -10934,6 +10934,11 @@
"integrity": "sha512-4gDntzrifFnCEvyoO8PqyJDmguXgVPxKiIxrBKjIowvL9l+N66196+72XVYR8BBf1Uv1Fgt3bGevJ+sEmxfZzw==",
"dev": true
},
"vuex": {
"version": "3.5.1",
"resolved": "https://registry.npmjs.org/vuex/-/vuex-3.5.1.tgz",
"integrity": "sha512-w7oJzmHQs0FM9LXodfskhw9wgKBiaB+totOdb8sNzbTB2KDCEEwEs29NzBZFh/lmEK1t5tDmM1vtsO7ubG1DFw=="
},
"watchpack": {
"version": "1.7.2",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.2.tgz",

View file

@ -16,12 +16,14 @@
"fork-awesome": "^1.1.7",
"vue": "^2.6.11",
"vue-i18n": "^8.17.3",
"vue-router": "^3.2.0"
"vue-router": "^3.2.0",
"vuex": "^3.4.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.4.0",
"@vue/cli-plugin-eslint": "~4.4.0",
"@vue/cli-plugin-router": "^4.4.6",
"@vue/cli-plugin-vuex": "^4.4.6",
"@vue/cli-service": "~4.4.0",
"babel-eslint": "^10.1.0",
"bootstrap": "^4.3.1",

View file

@ -3,6 +3,7 @@ import App from './App.vue'
import './plugins/bootstrap-vue'
import i18n from './plugins/i18n'
import router from './plugins/router'
import store from './plugins/store'
import * as globalsComponents from './components/globals'
@ -14,9 +15,9 @@ for (let component of Object.values(globalsComponents)) {
Vue.component(component.name, component)
}
new Vue({
i18n,
router,
store,
render: h => h(App),
}).$mount('#app')

21
app/src/plugins/store.js Normal file
View file

@ -0,0 +1,21 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
connected: localStorage.getItem('connected') === 'true'
},
mutations: {
['CONNECTED'] (state, connected) {
localStorage.setItem('connected', connected)
state.connected = connected
},
},
actions: {
},
modules: {
}
})