import createPersistedState from 'vuex-persistedstate'

import Vue from 'vue'
import Vuex from 'vuex'
import login from '@/store/login.js'
import menu from '@/store/menu.js'
import storeProcess from '@/store/storeProcess.js'
import user from '@/store/user.js'
import oftenFlow from '@/store/oftenFlow.js'
import mail from '@/store/mail.js'
import approvalItem from '@/store/approvalItemList.js'
import messageReceiver from '@/store/messageReceiverList.js'
import agent from '@/store/agentList.js'
import deputy from '@/store/bpmDeputy.js'
import form from '@/store/formStore.js'
import relatedProcess from '@/store/relatedProcess.js'
import dialog from '@/store/dialogStore.js'
import index from '@/store/index.js'
import system from '@/store/system'

Vue.use(Vuex)

const debug = process.env.NODE_ENV !== 'production'

export default new Vuex.Store({
  modules: {
    login,
    menu,
    storeProcess,
    user,
    oftenFlow,
    mail,
    approvalItem,
    messageReceiver,
    agent,
    deputy,
    form,
    relatedProcess,
    dialog,
    index,
    system
  },
  strict: debug,
  plugins: [
    createPersistedState({
      key: 'vuex', // 存储的键名
      paths: ['system'], // 仅缓存 system 模块
      storage: window.localStorage // 使用 localStorage 持久化
    })
  ]
})
