Merge pull request #7 from EslSuwen/master

🩹 文章列表请求增加当前页判断
This commit is contained in:
ronger 2021-02-20 09:55:59 +08:00 committed by GitHub
commit e6730d4011
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -64,15 +64,20 @@ export const mutations = {
export const actions = { export const actions = {
// 获取文章列表 // 获取文章列表
fetchList({commit}, params = {}) { fetchList({commit, state}, params = {}) {
commit('updateListFetching', true)
// 当前页判断
let currentData = JSON.parse(JSON.stringify(state)).list.data
if (Number(params.page) === currentData.pagination.currentPage) {
commit('updateListFetching', false)
return
}
// 清空已有数据 // 清空已有数据
commit('updateListData', getDefaultListData()) commit('updateListData', getDefaultListData())
commit('updateListFetching', true)
let data = { let data = {
page: params.page || 1, page: params.page || 1,
topicUri: params.topic_uri || '' topicUri: params.topic_uri || ''
} }
return this.$axios return this.$axios
.$get(`${BASE_API_PATH}/articles`, { .$get(`${BASE_API_PATH}/articles`, {
params: data params: data
@ -87,7 +92,7 @@ export const actions = {
}); });
}, },
// 获取文章详情 // 获取文章详情
fetchDetail({ commit }, params = {}) { fetchDetail({commit, state}, params = {}) {
// const delay = fetchDelay( // const delay = fetchDelay(
// isBrowser // isBrowser
// ) // )
@ -97,6 +102,12 @@ export const actions = {
// }) // })
// } // }
commit('updateDetailFetching', true) commit('updateDetailFetching', true)
// 当前文章判断
let currentData = JSON.parse(JSON.stringify(state)).detail.data
if (Number(params.article_id) === currentData.idArticle) {
commit('updateDetailFetching', false)
return
}
// commit('updateDetailData', {}) // commit('updateDetailData', {})
return this.$axios return this.$axios
.$get(`${BASE_API_PATH}/article/${params.article_id}`) .$get(`${BASE_API_PATH}/article/${params.article_id}`)