import Vue from 'vue'
import Vuex from 'vuex'
// import router from '@/router'
import action from '@action'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    classify: {}
  },
  getters: {},
  mutations: {
    setClassify(state, classify) {
      state.classify = classify
    }
  },
  actions: {
    logout() {
      return logout().then(() => {
        // router.push('/')
        window.location.href = '/'
      })
    },
    getClassify({ commit }) {
      action.articleAction.getAllClassify().then(response => {
        commit('setClassify', response.data)
      })
    }
  }
})
export default store
store.dispatch('getClassify')
