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 }