From aa8cbb847d7fd6ecfa9160f4a7596a1c4e384dcd Mon Sep 17 00:00:00 2001 From: xiaonuobase <1253070437@qq.com> Date: Wed, 19 Apr 2023 17:54:43 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E5=8D=87=E7=BA=A7=E3=80=91=E9=80=80?= =?UTF-8?q?=E5=87=BA=E5=90=8E=E8=B7=AF=E7=94=B1=E5=9B=9E=E5=88=B0=E7=99=BB?= =?UTF-8?q?=E9=99=86=E5=89=8D=E4=BD=BF=E7=94=A8=E7=9A=84=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E6=84=9F=E8=B0=A2=E7=A0=81=E4=BA=91=20=E5=86=AC?= =?UTF-8?q?=E5=A4=A9=20=E5=BB=BA=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snowy-admin-web/src/router/index.js | 3 +++ snowy-admin-web/src/style/index.less | 1 - snowy-admin-web/src/views/auth/login/util.js | 8 ++++++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/snowy-admin-web/src/router/index.js b/snowy-admin-web/src/router/index.js index 70f67f4a..f5ddf48b 100644 --- a/snowy-admin-web/src/router/index.js +++ b/snowy-admin-web/src/router/index.js @@ -85,6 +85,9 @@ router.beforeEach(async (to, from, next) => { isGetRouter.value = false next() return false + } else { + // 这里需要使用 localStorage 保存登录之前要访问的页面 + tool.data.set('LAST_VIEWS_PATH', to.fullPath) } if (!token) { next({ diff --git a/snowy-admin-web/src/style/index.less b/snowy-admin-web/src/style/index.less index b146d7a5..fafd8ca2 100644 --- a/snowy-admin-web/src/style/index.less +++ b/snowy-admin-web/src/style/index.less @@ -36,7 +36,6 @@ a, button, input, textarea { .aminui { overflow: hidden; height: 100%; - min-height: 640px; display: flex; flex-flow: column; } diff --git a/snowy-admin-web/src/views/auth/login/util.js b/snowy-admin-web/src/views/auth/login/util.js index 03a01f5c..df4cbc3d 100644 --- a/snowy-admin-web/src/views/auth/login/util.js +++ b/snowy-admin-web/src/views/auth/login/util.js @@ -16,12 +16,16 @@ export const afterLogin = async (loginToken) => { // 获取用户的菜单 const menu = await userCenterApi.userLoginMenu() - const indexMenu = menu[0].children[0].path + let indexMenu = menu[0].children[0].path tool.data.set('MENU', menu) // 重置系统默认应用 tool.data.set('SNOWY_MENU_MODULE_ID', menu[0].id) message.success('登录成功') - router.replace({ + if (!!tool.data.get('LAST_VIEWS_PATH')) { + // 如果有缓存,将其登录跳转到最后访问的路由 + indexMenu = tool.data.get('LAST_VIEWS_PATH') + } + await router.replace({ path: indexMenu }) dictApi.dictTree().then((data) => {