From 71c8ca441192ff660e6bfade83d199a6f27c497f Mon Sep 17 00:00:00 2001 From: aiteam_chentao Date: Tue, 9 Feb 2021 11:22:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E6=9D=83=E9=99=90=E6=88=96?= =?UTF-8?q?=E8=80=85=E9=80=80=E5=87=BA=E7=99=BB=E5=BD=95=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E5=88=B0=E7=99=BB=E5=BD=95=E9=A1=B5=E9=9D=A2=E6=97=B6=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E9=A1=B5=E9=9D=A2url=E7=9A=84query=E6=9C=AA=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/Navbar.vue | 3 ++- src/permission.js | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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() } }