feat: 新增地址栏记录查询条件功能#60 (halo-dev/console#65)

pull/3445/head
Ryan Wang 2020-02-17 15:19:43 +08:00 committed by GitHub
parent 04c604836a
commit 274b6178ee
1 changed files with 22 additions and 0 deletions

View File

@ -630,12 +630,34 @@ export default {
this.postSettingVisible = false
}
},
beforeRouteEnter(to, from, next) {
next(vm => {
vm.queryParam.page = to.query.page
vm.queryParam.size = to.query.size
vm.queryParam.sort = to.query.sort
vm.queryParam.keyword = to.query.keyword
vm.queryParam.categoryId = to.query.categoryId
vm.queryParam.status = to.query.status
})
},
beforeRouteLeave(to, from, next) {
if (this.postSettingVisible) {
this.postSettingVisible = false
}
next()
},
watch: {
queryParam: {
deep: true,
handler: function(newVal, oldVal) {
if (newVal) {
const params = JSON.parse(JSON.stringify(this.queryParam))
const path = this.$router.history.current.path
this.$router.push({ path, query: params }).catch(err => err)
}
}
}
},
methods: {
loadPosts() {
this.postsLoading = true