nebula/pages/portfolios.vue
2021-03-06 21:29:35 +08:00

55 lines
1.1 KiB
Vue

<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},
fetch({store, query, error}) {
return Promise.all([
store
.dispatch('portfolio/fetchList', {page: query.page || 1})
.catch(err => error({statusCode: 404}))
])
},
watch: {
'$route.query': function () {
this.$store.dispatch('portfolio/fetchList', {page: this.$route.query.page || 1})
}
},
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>