2020-06-19 17:10:44 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
2021-05-07 08:26:51 +08:00
|
|
|
<announcement-list :announcements="announcements"></announcement-list>
|
2020-06-22 17:13:42 +08:00
|
|
|
<article-list :articles="articles" @currentChange="currentChangeArticle"></article-list>
|
2020-06-19 17:10:44 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
2020-06-22 17:13:42 +08:00
|
|
|
<script>
|
2021-02-03 16:10:57 +08:00
|
|
|
import ArticleList from '~/components/archive/list'
|
2021-05-07 08:26:51 +08:00
|
|
|
import AnnouncementList from '~/components/announcement/list'
|
2021-02-03 16:10:57 +08:00
|
|
|
import {mapState} from 'vuex';
|
2020-07-03 11:04:25 +08:00
|
|
|
|
2021-02-03 16:10:57 +08:00
|
|
|
export default {
|
|
|
|
name: 'Index',
|
2022-10-09 09:42:21 +08:00
|
|
|
fetch() {
|
|
|
|
let {store, query, error} = this.$nuxt.context
|
2021-02-03 16:10:57 +08:00
|
|
|
return Promise.all([
|
2021-05-07 08:26:51 +08:00
|
|
|
store.dispatch('article/fetchList', {page: query.page || 1}),
|
|
|
|
store.dispatch('article/fetchAnnouncementList', {page: query.page || 1})
|
2021-02-03 16:10:57 +08:00
|
|
|
])
|
|
|
|
},
|
|
|
|
watch: {
|
2022-10-30 16:56:15 +08:00
|
|
|
'$route'(to, from) {
|
2023-03-24 11:59:37 +08:00
|
|
|
if ((to.query.page || 1) !== (from.query.page || 1)) {
|
2022-10-30 16:56:15 +08:00
|
|
|
this.$router.go()
|
|
|
|
}
|
2021-02-03 16:10:57 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
2021-05-07 08:26:51 +08:00
|
|
|
AnnouncementList,
|
2021-02-03 16:10:57 +08:00
|
|
|
ArticleList
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
...mapState({
|
2021-05-07 08:26:51 +08:00
|
|
|
articles: state => state.article.list.data,
|
|
|
|
announcements: state => state.article.announcements.data
|
2021-02-03 16:10:57 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
currentChangeArticle(page) {
|
|
|
|
this.$router.push({
|
|
|
|
name: 'index',
|
|
|
|
query: {
|
|
|
|
page: page
|
|
|
|
}
|
2020-08-02 00:25:44 +08:00
|
|
|
})
|
2020-06-22 17:13:42 +08:00
|
|
|
}
|
2021-02-03 16:10:57 +08:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.$store.commit('setActiveMenu', 'index')
|
2020-06-22 17:13:42 +08:00
|
|
|
}
|
2021-02-03 16:10:57 +08:00
|
|
|
}
|
2020-06-22 17:13:42 +08:00
|
|
|
</script>
|
2020-06-19 17:10:44 +08:00
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
</style>
|