diff --git a/package.json b/package.json index 1967d28..baf8aa1 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "loopback": "^3.0.0", "loopback-boot": "^2.6.5", "loopback-component-explorer": "^4.0.0", + "lz-string": "^1.4.4", "strong-error-handler": "^1.0.1", "vue": "^2.1.10", "vue-router": "^2.2.0", diff --git a/src/store/index.js b/src/store/index.js index b08fa40..aae0936 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,6 +1,7 @@ import Vue from 'vue'; import Vuex from 'vuex'; import createPersistedState from 'vuex-persistedstate'; +import lz from 'lz-string'; import authentication from './authentication'; @@ -13,7 +14,16 @@ const store = new Vuex.Store({ authentication, }, plugins: [ - createPersistedState(), + createPersistedState({ + getState(key) { + const state = lz.decompress(window.localStorage.getItem(key)); + return JSON.parse(state); + }, + setState(key, state) { + const stateJSON = JSON.stringify(state); + return window.localStorage.setItem(key, lz.compress(stateJSON)); + }, + }), ], }); diff --git a/yarn.lock b/yarn.lock index 38eaeec..ab28747 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3616,6 +3616,10 @@ lru-cache@^4.0.1: pseudomap "^1.0.1" yallist "^2.0.0" +lz-string@^1.4.4: + version "1.4.4" + resolved "https://registry.yarnpkg.com/lz-string/-/lz-string-1.4.4.tgz#c0d8eaf36059f705796e1e344811cf4c498d3a26" + macaddress@^0.2.8: version "0.2.8" resolved "https://registry.yarnpkg.com/macaddress/-/macaddress-0.2.8.tgz#5904dc537c39ec6dbefeae902327135fa8511f12"