diff --git a/package-lock.json b/package-lock.json index 89ede80..85bf605 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8185,6 +8185,11 @@ "integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=", "dev": true }, + "lodash.merge": { + "version": "4.6.1", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.1.tgz", + "integrity": "sha512-AOYza4+Hf5z1/0Hztxpm2/xiPZgi/cjMqdnKTUWTBSKchJlxXXuUSxCCl8rJlf4g6yww/j6mA8nC8Hw/EZWxKQ==" + }, "lodash.mergewith": { "version": "4.6.1", "resolved": "https://registry.npmjs.org/lodash.mergewith/-/lodash.mergewith-4.6.1.tgz", @@ -13875,6 +13880,14 @@ "resolved": "https://registry.npmjs.org/vuex/-/vuex-3.0.1.tgz", "integrity": "sha512-wLoqz0B7DSZtgbWL1ShIBBCjv22GV5U+vcBFox658g6V0s4wZV9P4YjCNyoHSyIBpj1f29JBoNQIqD82cR4O3w==" }, + "vuex-persist": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/vuex-persist/-/vuex-persist-1.4.0.tgz", + "integrity": "sha512-3R8vMa4o1hBoCdgGQ9xFl8ZpEjMSlU3UFAdPTSg06a2UK2NTFvfiBsrFHr9QWyTxzxt65W0Bamu5qdENTH5tMQ==", + "requires": { + "lodash.merge": "4.6.1" + } + }, "w3c-hr-time": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", diff --git a/package.json b/package.json index 1c79afa..2300c55 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ }, "dependencies": { "vue": "^2.5.2", - "vuex": "^3.0.1" + "vuex": "^3.0.1", + "vuex-persist": "^1.4.0" }, "devDependencies": { "autoprefixer": "^7.1.2", diff --git a/src/store/index.js b/src/store/index.js index be103cd..477f97c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,8 +1,15 @@ import Vue from 'vue' import Vuex from 'vuex' +import VuexPersist from 'vuex-persist' Vue.use(Vuex) +// Set up persistent storage +const vuexlocalstorage = new VuexPersist({ + key: 'railway-simulator', + storage: window.localStorage +}) + const state = { money: 100, workers: 0 @@ -48,5 +55,6 @@ export default new Vuex.Store({ state, getters, mutations, - actions + actions, + plugins: [vuexlocalstorage.plugin] })