import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

let status_time = 24 * 60 * 60 * 1000

export default new Vuex.Store({
  state: {
    token: "",
    userState: false,
    userInfo: null,
    menuDataList: [],
  },
  getters: {
    getToken: function (state) {
      return Vue.ls.get("token")
    },
    getUserState: function (state) {
      return Vue.ls.get("userState")
    },
    getUserInfo: function (state) {
      return JSON.parse(Vue.ls.get("userInfo"))
    },
  },
  mutations: {
    setToken(state, str) {
      state.token = str;
      Vue.ls.set("token", str, status_time);
    },
    setUserState(state, bool) {
      state.userState = bool;
      Vue.ls.set("userState", bool, status_time);
    },
    setUserInfo(state, obj) {
      state.userInfo = obj;
      Vue.ls.set("userInfo", JSON.stringify(obj), status_time);
    },
    setMenuDataList(state, arr) {
      state.menuDataList = arr.concat([]);
    }
  },
  actions: {
    // changeClassificationData(context, arr) {
    //   context.commit('setClassificationData', arr)
    // },
  },
  modules: {},
})
