diff --git a/src/layout/components/Navbar.vue b/src/layout/components/Navbar.vue index 37bc1e69..05f193c0 100644 --- a/src/layout/components/Navbar.vue +++ b/src/layout/components/Navbar.vue @@ -76,7 +76,8 @@ export default { }, async logout() { await this.$store.dispatch('user/logout') - this.$router.push(`/login?redirect=${this.$route.fullPath}`) + const { path, query } = this.$route + this.$router.push({ path: '/login', query: { redirect: path, ...query }}) } } } diff --git a/src/permission.js b/src/permission.js index ff5eaad2..53f6aa5c 100644 --- a/src/permission.js +++ b/src/permission.js @@ -49,7 +49,7 @@ router.beforeEach(async(to, from, next) => { // remove token and go to login page to re-login await store.dispatch('user/resetToken') Message.error(error || 'Has Error') - next(`/login?redirect=${to.path}`) + next({ path: '/login', query: { redirect: to.path, ...to.query }}) NProgress.done() } } @@ -62,7 +62,7 @@ router.beforeEach(async(to, from, next) => { next() } else { // other pages that do not have permission to access are redirected to the login page. - next(`/login?redirect=${to.path}`) + next({ path: '/login', query: { redirect: to.path, ...to.query }}) NProgress.done() } }