Created
August 22, 2020 13:53
-
-
Save alifrizkip/f9b23f37dd52263f39ebc9811213d079 to your computer and use it in GitHub Desktop.
index-secure-ls-persistedstate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue'; | |
import Vuex from 'vuex'; | |
import createPersistedState from 'vuex-persistedstate'; | |
import SecureLS from "secure-ls"; | |
import cart from './modules/cart'; | |
Vue.use(Vuex); | |
const secureLS = new SecureLS({ | |
encodingType: 'aes', | |
encryptionSecret: 'vue-cart-persist' | |
}); | |
const cartState = createPersistedState({ | |
key: 'cart-persist-state', | |
paths: ['cart.carts'], | |
storage: { | |
getItem: (key) => secureLS.get(key), | |
setItem: (key, value) => secureLS.set(key, value), | |
removeItem: (key) => secureLS.remove(key), | |
}, | |
}); | |
const store = new Vuex.Store({ | |
modules: { | |
cart, | |
}, | |
plugins: [cartState], | |
}); | |
export default store; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment