import vue from 'vue'
import vuex from 'vuex'

vue.use(vuex)

export default new vuex.Store({
  state: {
    routes: [],
    userInfo: []
  },

  // 同步
  mutations: {
    initRoutes(state, data) {
      state.routes = data;
      localStorage.setItem("routers", JSON.stringify(data));
    },

    removeState(state) {
      state.routes = []
      state.userInfo = []
      localStorage.removeItem("routers");
      localStorage.removeItem("userInfo");
    },

    userInfo(state, data) {
      state.userInfo = data;
      localStorage.setItem("userInfo", JSON.stringify(data));
    }
  },

  // 异步
  actions: {}

})

