add lz compression to localstorage state
This commit is contained in:
@@ -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));
|
||||
},
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user