From 9e0f74f8c02cb53f978dc41d9c6b52c70a85c647 Mon Sep 17 00:00:00 2001 From: ronger Date: Mon, 15 Mar 2021 21:16:01 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=B6=88=E6=81=AF=E6=A0=87=E8=AE=B0?= =?UTF-8?q?=E5=B7=B2=E8=AF=BB=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/common/notification/list.vue | 1 + store/notification.js | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/components/common/notification/list.vue b/components/common/notification/list.vue index 7303acb..a8dde54 100644 --- a/components/common/notification/list.vue +++ b/components/common/notification/list.vue @@ -85,6 +85,7 @@ read(id) { let _ts = this; this.$axios.$put('/api/notification/read/' + id).then(function () { + _ts.$store.commit('notification/updateState', true) _ts.currentChange(1); }).catch(error => console.log(error)); }, diff --git a/store/notification.js b/store/notification.js index b01cd85..13025ad 100644 --- a/store/notification.js +++ b/store/notification.js @@ -12,7 +12,8 @@ export const state = () => { list: { fetching: false, data: getDefaultListData() - } + }, + updateState: false } } @@ -23,6 +24,9 @@ export const mutations = { }, updateListData(state, action) { state.list.data = action + }, + updateState(state, action) { + state.updateState = action } } @@ -33,15 +37,20 @@ export const actions = { commit('updateListFetching', true) // 当前页判断 let currentData = JSON.parse(JSON.stringify(state)).list.data - if (Number(params.page) === currentData.pagination.currentPage) { - commit('updateListFetching', false) - return + let updateState = state.updateState + if (!updateState) { + if (Number(params.page) === currentData?.pagination.currentPage) { + commit('updateListFetching', false) + return + } } commit('updateListData', getDefaultListData()) let data = { page: params.page || 1 } + commit('updateState', false) + return this.$axios .$get(`${NOTIFICATION_API_PATH}/all`, { params: data