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) => {