vuex数据持久化处理

2年前 (2022) 程序员胖胖胖虎阿
131 0 0

主要应用插件vuex-persistedstate

import Vue from "vue";
import Vuex from "vuex";
import storeSidebar from "./storeSidebar";
import storeConsole from "./storeConsole";
import storeLogin from "./storeLogin";
import storeUrl from "./storeUrl";
import storeUserFliters from "./storeUserFliters";
import storeRoleFliters from "./storeRoleFliters";
import storeUser from "./storeUser";
import storeRole from "./storeRole";
import storeWidget from "./storeWidget";
import storeOrgan from "./storeOrgan";
import storeUserImage from "./storeUserImage";
import CreatePersistedState from "vuex-persistedstate";
Vue.use(Vuex);

export default new Vuex.Store({
  state: {},
  mutations: {},
  actions: {},
  modules: {
    storeSidebar,
    storeConsole,
    storeLogin,
    storeUrl,
    storeUserFliters,
    storeUser,
    storeWidget,
    storeRoleFliters,
    storeRole,
    storeOrgan,
    storeUserImage
  },
  plugins: [
    CreatePersistedState({
      reducer(val) {
        return {
          assessmentData: val.storeLogin,
          storeSidebar: val.storeSidebar,
          storeUserImage: {
            userImage: val.storeUserImage.userImage
          },
          storeUrl: {
            url: val.storeUrl.url,
            MenuList: val.storeUrl.MenuList,
            RelationList: val.storeUrl.RelationList,
            appList: val.storeUrl.appList
          }
        };
      }
    })
  ]
});
版权声明:程序员胖胖胖虎阿 发表于 2022年11月24日 上午11:32。
转载请注明:vuex数据持久化处理 | 胖虎的工具箱-编程导航

相关文章

暂无评论

暂无评论...