You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Plugin for working with Vuex. Allows you to select the type of storage, localStorage or sessionStorage for storing state. It is possible to "mask" data in the storage cell.
The plugin uses one storage key in which it stores masked data. DO NOT USE FOR STORING CONFIDENTIAL DATA. Just a masking.
Encryption keys are generated automatically, you cannot set the keys yourself. Perhaps it will be implemented in the next versions. Or maybe not.
import{MaskedVuex,maskedVuex}from'vuex-masked-modules';exportconststorageName='app';// key in localStorageexportconstnamespace='ModuleName';// key in store, module nameexportconstisEncrypt=true;// encrypt (masked) data or notexportconstisMaskedKey=true;// masked key in store or notexportconstisInitLog=true;// show store object in consoleexportconststorageType='sessionStorage';// select type store. 'localStorage' (default) or 'sessionStorage'exportconstisFlush=false;// flush store// middlewares functionsexportconstmiddlewares=[({type, payload})=>console.log(type,payload),];// data template (state)exportconsttemplate={arr: [2,4,6],isVisible: false};exportconstsettings={
storageName,
namespace,
isEncrypt,
isMaskedKey,
isInitLog,
isFlush,
middlewares,
storageType,
template,};conststate=newMaskedVuex({ ...settings});exportconstplugin=({namespace})=>maskedVuex({ ...settings, namespace });exportdefault{namespaced: true,mutations: {show(state){state.isVisible=true;},hide(state){state.isVisible=false;}},getters: {test(state){returnstate.arr.map(item=>item*2);}},
namespace,
state,
plugin
};