/* * @Author: 廖明明 * @Date: 2022-03-31 16:36:19 * @LastEditors: 廖明明 * @LastEditTime: 2022-04-22 10:16:40 * @Description:vuex入口文件 */ import Vue from "vue"; import Vuex from "vuex"; import other from "./modules/other"; import user from "./modules/user"; import dictionary from "./modules/dictionary"; import system from "./modules/system"; Vue.use(Vuex); const myPlugin = (store) => { // 当 store 初始化后调用 let vuexStorage = uni.getStorageSync("vuexStorage"); if ( vuexStorage && vuexStorage.user && vuexStorage.dictionary && vuexStorage.system && vuexStorage.other ) { store.replaceState(vuexStorage); } store.subscribe((mutation, state) => { uni.setStorageSync("vuexStorage", state); }); }; export default new Vuex.Store({ modules: { user, dictionary, system, other, }, plugins: [myPlugin], });