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

pull/66/head
Ryan Wang 2020-02-17 15:19:43 +08:00 committed by GitHub
parent 643cf5524c
commit 0d6ebd0733
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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