nebula/store/topic.js

39 lines
765 B
JavaScript
Raw Normal View History

2020-07-31 17:40:17 +08:00
/**
* @file 分类数据状态 / ES module
* @module store/category
2020-08-01 00:39:29 +08:00
* @author Ronger <https://github.com/ronger-x>
2020-07-31 17:40:17 +08:00
*/
export const TOPIC_API_PATH = '/api/topic'
export const state = () => {
return {
fetching: false,
data: []
}
}
export const mutations = {
updateFetching(state, action) {
state.fetching = action
},
updateListData(state, action) {
state.data = action
}
}
export const actions = {
fetchList({ commit }, params) {
2020-08-01 00:39:29 +08:00
commit('updateFetching', true);
2020-07-31 17:40:17 +08:00
return this.$axios
.$get(`${TOPIC_API_PATH}/topic-nav`)
.then(response => {
commit('updateListData', response)
commit('updateFetching', false)
})
.catch(error => {
commit('updateFetching', false)
})
}
}