import Vue from 'vue'
import Vuex from 'vuex'
import cloneDeep from 'lodash/cloneDeep'
import common from './modules/common'
import user from './modules/user'
import settings from './modules/settings'
import connect from './modules/connect'
import monitor from './modules/monitor'
// import {getMetrics,getScheduler,getToken,getNodes} from '../utils/token'
Vue.use(Vuex)

const store = new Vuex.Store({
  modules: {
    common,
    user,
    settings,
    connect,
    monitor
  },
  mutations: {
    // 重置vuex本地储存状态
    resetStore (state) {
      Object.keys(state).forEach((key) => {
        state[key] = cloneDeep(window.SITE_CONFIG['storeState'][key])
      })
    }
  },
  strict: process.env.NODE_ENV !== 'production'
})

export default store

// import Vue from 'vue';
// import Vuex from 'vuex';
// import { getMetrics, getScheduler, getToken } from './../utils/token';
// Vue.use(Vuex);
// const store = new Vuex.Store({
//   state: { // 存储token
//     Authorization: localStorage.getItem('Authorization') ? localStorage.getItem('Authorization') : ''
//   },
//   mutations: { // 修改token，并将token存入 localStorage
//     changeLogin(state, user) {
//       state.Authorization = user.Authorization;
//       localStorage.setItem('Authorization', user.Authorization);
//     }
//   }
// });

// export default store
