Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non compatible anymore with Vuex (Vue.js State Store) #56

Open
BonBonSlick opened this issue Jun 30, 2021 · 1 comment
Open

Non compatible anymore with Vuex (Vue.js State Store) #56

BonBonSlick opened this issue Jun 30, 2021 · 1 comment

Comments

@BonBonSlick
Copy link

BonBonSlick commented Jun 30, 2021

'use strict';
// https://github.com/championswimmer/vuex-persist#readme
import createPersistedState from 'vuex-persistedstate';

import SecureLS from 'secure-ls';

const encryptedLocalStorage = new SecureLS(
    {
        encodingType: 'aes',
        encryptionSecret: 'D#xsQ6>P(_)Wrw;A',
        isCompression: false,
    },
);

const plugins = [
    createPersistedState({
                             storage: {
                                 getItem:    key => encryptedLocalStorage.get(key),
                                 setItem:    (key, value) => encryptedLocalStorage.set(key, value),
                                 removeItem: key => encryptedLocalStorage.remove(key),
                             },
                         }),
];

export default plugins;

import plugins                from './plugin/plugins';
import Vuex, {ModuleTree}     from 'vuex';
import Vue                    from 'vue';

Vue.use(Vuex);
const store = new Vuex.Store(
    {
        strict: 'production' !== process.env.NODE_ENV,
        devtools:  'production' !== process.env.NODE_ENV,
        modules,
        plugins,
    },
);
export default store;

Impossible to clear, update cached, encoded values. They are always old, outdated which cause a lot of issues, like expired token and its impossible to replace it.
Possibly related to
https://github.com/championswimmer/vuex-persist#readme
and
removeItem: key => encryptedLocalStorage.remove(key),

 "secure-ls": "^1.2.6",
    "source-map-loader": "^0.2.4",
    "standard": "^14.3.1",
    "uglifyjs-webpack-plugin": "^2.1.3",
    "url-loader": "^4.1.1",
    "vue": "^2.6.11",
    "vue-class-component": "^7.2.3",
    "vue-property-decorator": "^9.1.2",
    "vue-resource": "^1.2.1",
    "vue-router": "^3.0.1",
    "vue-router-multiguard": "^1.0.3",
    "vue-style-loader": "^4.1.0",
    "vue-template-loader": "^1.1.0",
    "vuex": "^3.0.1",
    "vuex-class": "^0.3.2",
    "vuex-persistedstate": "^4.0.0-beta.3",
    "vuex-router-sync": "^5.0.0"
@AleksKamb
Copy link

I know you can pass namespaced modules as a "paths" property with an array as value to the persistedState config object. Try targeting the modules you'd like to persist.
I have a working implementation of persistedState with SecureLs, however I am only using it to keep information about the current theme which in this case is a boolean value. Works fine though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants