/**
 * vuex状态管理
 */
import Vue from 'vue';
import Vuex from 'vuex';
import getters from './getters';
import dict from './modules/dict';
import user from './modules/user';
import theme from './modules/theme';
import selectCache from './modules/selectCache';
import team from './modules/team';
import createPersistedState from 'vuex-persistedstate';

import { SYSTEM_NAME } from '@/config/setting';
Vue.use(Vuex);

export default new Vuex.Store({
  state: {},
  mutations: {},
  actions: {},
  modules: {
    dict,
    user,
    theme,
    selectCache,
    team
  },
  getters,
  plugins: [
    createPersistedState({
      key: window.__POWERED_BY_QIANKUN__
        ? `vuex-${SYSTEM_NAME}`
        : `private-vuex-${SYSTEM_NAME}`,
      storage: window.sessionStorage,
      paths: ['user']
    })
  ] //会自动保存创建的状态。刷新还在
});
