nebula/pages/notification.vue

58 lines
1.3 KiB
Vue
Raw Normal View History

2020-08-02 19:21:51 +08:00
<template>
<el-row class="wrapper">
<el-col style="margin-bottom: 1rem;">
<h1>通知</h1>
</el-col>
<notification-list :notifications="notifications" @currentChange="currentChangeNotification"></notification-list>
</el-row>
</template>
<script>
import NotificationList from '~/components/common/notification/list';
import {mapState} from 'vuex';
export default {
name: "Notification",
2022-10-27 23:22:46 +08:00
middleware: 'auth',
2020-08-02 19:21:51 +08:00
components: {
NotificationList
},
2022-10-09 09:42:21 +08:00
fetch() {
let {store, query, error} = this.$nuxt.context
2020-08-02 19:21:51 +08:00
return Promise.all([
store
2021-03-06 09:59:38 +08:00
.dispatch('notification/fetchList', {page: query.page || 1})
2020-08-02 19:21:51 +08:00
.catch(err => error({statusCode: 404}))
])
},
2021-03-06 09:59:38 +08:00
watch: {
'$route.query': function () {
this.$store.dispatch('notification/fetchList', {page: this.$route.query.page || 1})
}
},
2020-08-02 19:21:51 +08:00
computed: {
...mapState({
notifications: state => state.notification.list.data,
2022-10-27 23:22:46 +08:00
user: state => state.auth.user
2020-08-02 19:21:51 +08:00
})
},
methods: {
currentChangeNotification(page) {
2021-03-06 09:59:38 +08:00
this.$router.push({
name: 'notification',
query: {
page: page
}
2020-08-02 19:21:51 +08:00
})
}
},
mounted() {
this.$store.commit('setActiveMenu', 'notification');
2020-08-02 19:21:51 +08:00
}
}
</script>
<style scoped>
</style>