Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import VuexPersistence from 'vuex-persist'
- import localforage from 'localforage'
- const vuexLocal = new VuexPersistence({
- storage: localforage,
- strictMode: false,
- asyncStorage: true,
- restoreState: (key, storage) => {
- return new Promise(resolve => {
- storage.getItem(key).then(data => {
- resolve(data)
- store._vm.$root.$emit('storageReady')
- store._vm.$root.storageReady = true
- if (data && data.auth && data.auth.token) {
- pAxios.defaults.headers.common['Authorization'] = data.auth.token
- }
- store.state.loading = false
- })
- })
- }
- })
- const store = new Vuex.Store({
- modules: {
- modules,
- },
- getters: {
- getBla: state => param => getBla(state, param),
- },
- state: {
- loading: true
- },
- plugins: [vuexLocal.plugin]
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement