From af361e297e179c8469ecba77f4422aafb90dca8a Mon Sep 17 00:00:00 2001 From: ronger Date: Sat, 6 Mar 2021 09:59:38 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=B6=88=E6=81=AF=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E5=88=86=E9=A1=B5=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/layouts/pc/main.vue | 4 ++-- pages/notification.vue | 16 ++++++++++++---- store/notification.js | 10 ++++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/components/layouts/pc/main.vue b/components/layouts/pc/main.vue index 919ffef..8a6e325 100644 --- a/components/layouts/pc/main.vue +++ b/components/layouts/pc/main.vue @@ -48,7 +48,7 @@ computed: { ...mapState('global', []), isPostArticle() { - if (this.$route.name == 'article-post-article_id') { + if (this.$route.name === 'article-post-article_id') { return false; } return true; @@ -92,7 +92,7 @@ .el-main { padding: 0; background-attachment: fixed; - min-height: 87.5vh; + min-height: 85vh; overflow-x: hidden; } diff --git a/pages/notification.vue b/pages/notification.vue index 9461368..f03155d 100644 --- a/pages/notification.vue +++ b/pages/notification.vue @@ -17,13 +17,18 @@ components: { NotificationList }, - fetch({store, error}) { + fetch({store, query, error}) { return Promise.all([ store - .dispatch('notification/fetchList') + .dispatch('notification/fetchList', {page: query.page || 1}) .catch(err => error({statusCode: 404})) ]) }, + watch: { + '$route.query': function () { + this.$store.dispatch('notification/fetchList', {page: this.$route.query.page || 1}) + } + }, computed: { ...mapState({ notifications: state => state.notification.list.data, @@ -32,8 +37,11 @@ }, methods: { currentChangeNotification(page) { - this.$store.dispatch('notification/fetchList', { - page: page + this.$router.push({ + name: 'notification', + query: { + page: page + } }) } }, diff --git a/store/notification.js b/store/notification.js index 3be3bbe..b01cd85 100644 --- a/store/notification.js +++ b/store/notification.js @@ -28,10 +28,16 @@ export const mutations = { export const actions = { // 获取消息列表 - fetchList({commit}, params = {}) { + fetchList({commit, state}, params = {}) { // 清空已有数据 - commit('updateListData', getDefaultListData()) 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()) let data = { page: params.page || 1 }