From cf62d2f5085459ce05820e2da6e023466f15b28d Mon Sep 17 00:00:00 2001 From: aixianling Date: Mon, 23 Dec 2024 09:20:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(router):=20=E4=BF=AE=E5=A4=8D=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E6=9C=AA=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在路由守卫中增加判断,当进入 Home 页面时,如果用户已登录但未获取用户信息,则自动获取用户信息 - 优化了用户体验,确保用户在访问首页时能够及时加载个人相关数据 --- src/utils/router.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/utils/router.js b/src/utils/router.js index 73524ce7..a3e14973 100644 --- a/src/utils/router.js +++ b/src/utils/router.js @@ -35,6 +35,8 @@ router.beforeEach((to, from, next) => { //数据大屏进行的独立页面跳转 let {query, hash} = to next({name: "数据大屏入口", query, hash}) + } else if (to.name == "Home" && user.token && !user.info?.id) { + dispatch("getUserInfo").then(() => next()) } else if (user.token) { to.name == "init" ? next({name: "Home"}) : next() } else {