From 520c89b3963e335be62c54a01e51c330ad4ee3bc Mon Sep 17 00:00:00 2001 From: suwen <577014284@qq.com> Date: Sat, 20 Feb 2021 09:52:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20=E6=96=87=E7=AB=A0=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=AF=B7=E6=B1=82=E5=A2=9E=E5=8A=A0=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E9=A1=B5=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- store/article.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/store/article.js b/store/article.js index b3ce57b..76c9218 100644 --- a/store/article.js +++ b/store/article.js @@ -64,15 +64,20 @@ export const mutations = { 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('updateListFetching', true) let data = { page: params.page || 1, topicUri: params.topic_uri || '' } - return this.$axios .$get(`${BASE_API_PATH}/articles`, { params: data @@ -87,7 +92,7 @@ export const actions = { }); }, // 获取文章详情 - fetchDetail({ commit }, params = {}) { + fetchDetail({commit, state}, params = {}) { // const delay = fetchDelay( // isBrowser // ) @@ -97,6 +102,12 @@ export const actions = { // }) // } 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', {}) return this.$axios .$get(`${BASE_API_PATH}/article/${params.article_id}`)