nebula/pages/portfolios.vue

58 lines
1.1 KiB
Vue
Raw Permalink Normal View History

2021-03-06 21:29:35 +08:00
<template>
<el-row class="wrapper">
<el-col>
<h1>最新作品集</h1>
</el-col>
<el-col>
<portfolio-list :portfolios="portfolios" @currentChange="currentChangePortfolio"></portfolio-list>
</el-col>
</el-row>
</template>
<script>
import {mapState} from "vuex";
import PortfolioList from "~/components/common/portfolio/list";
export default {
name: "Portfolios",
components: {PortfolioList},
2022-10-09 09:42:21 +08:00
fetch() {
2022-10-11 11:13:49 +08:00
let {store, query, error} = this.$nuxt.context
2021-03-06 21:29:35 +08:00
return Promise.all([
store
.dispatch('portfolio/fetchList', {page: query.page || 1})
.catch(err => error({statusCode: 404}))
])
},
watch: {
'$route'(to, from) {
if (from.query.page && to.query.page) {
this.$router.go()
}
2021-03-06 21:29:35 +08:00
}
},
computed: {
...mapState({
portfolios: state => state.portfolio.list.data
})
},
methods: {
currentChangePortfolio(page) {
this.$router.push({
name: 'portfolios',
query: {
page: page
}
})
}
},
mounted() {
this.$store.commit('setActiveMenu', 'portfolios');
}
}
</script>
<style scoped>
</style>