export default {
  namespaced: true, //子模块一定要开启命名空间
  state: {
    breadcrumbList: [],
    currentUrl: ''
  },
  mutations: {
    //面包屑
    ADD_BREAD(state, obj) {
      // console.log(state, obj)
      localStorage.setItem('breadcrumbList', JSON.stringify(obj))
      const result = JSON.parse(localStorage.getItem('breadcrumbList')) || []
      state.breadcrumbList = result
    },
    EDIT_BREAD(state, obj) {
      console.log(state, obj)
      localStorage.setItem('currentUrl', JSON.stringify(obj))
      const result = JSON.parse(localStorage.getItem('currentUrl')) || []
      state.currentUrl = result
    }
  },
  actions: {
    getUserMessage(context, obj) {
      //obj为对象
      if (obj.code == 200) {
        //提交ADD_DATA
        context.commit('ADD_BREAD', obj)
      } else {
        console.log('error')
      }
    }
  },
  getters: {
    // state的计算属性，监听state的变化时对state里的数据进行加工
    //如果其他组件都需要相同的函数，就可以把函数写到这里面
  }
}
