import Vue from "vue";
import Vuex from "vuex";
import user from "./modules/user";
import createPersistedState from "vuex-persistedstate";
import VuexReset from "@ianwalter/vuex-reset";
import { SessionCrypto } from "@/utils";
Vue.use(Vuex);

export default new Vuex.Store({
  state: {},
  getters: {},
  mutations: {},
  actions: {},
  modules: {
    user,
  },
  plugins: [
    // 重置状态插件
    VuexReset(),
    // 持久化插件
    createPersistedState({
      key: "info",
      storage: {
        getItem: (key) => SessionCrypto.getItem(key),
        setItem: (key, value) => SessionCrypto.setItem(key, value),
        removeItem: (key) => SessionCrypto.remove(key),
      },
    }),
  ],
});
