From 6fb98f2195df888534751d3e2a1ac9490584bebb Mon Sep 17 00:00:00 2001 From: Axolotle Date: Fri, 10 Jul 2020 18:38:59 +0200 Subject: [PATCH] add vuex store with 'connected' state --- app/package-lock.json | 5 +++++ app/package.json | 4 +++- app/src/main.js | 5 +++-- app/src/plugins/store.js | 21 +++++++++++++++++++++ 4 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 app/src/plugins/store.js diff --git a/app/package-lock.json b/app/package-lock.json index 4925f807..753321a1 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -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", diff --git a/app/package.json b/app/package.json index 7b05895e..fed26952 100644 --- a/app/package.json +++ b/app/package.json @@ -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", diff --git a/app/src/main.js b/app/src/main.js index f7663c59..faeff0e2 100644 --- a/app/src/main.js +++ b/app/src/main.js @@ -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' @@ -11,12 +12,12 @@ Vue.config.productionTip = false // Register global components for (let component of Object.values(globalsComponents)) { - Vue.component(component.name, component) + Vue.component(component.name, component) } - new Vue({ i18n, router, + store, render: h => h(App), }).$mount('#app') diff --git a/app/src/plugins/store.js b/app/src/plugins/store.js new file mode 100644 index 00000000..a9b011d2 --- /dev/null +++ b/app/src/plugins/store.js @@ -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: { + } +})