fix(router): 修复首页未获取用户信息的问题

- 在路由守卫中增加判断,当进入 Home 页面时,如果用户已登录但未获取用户信息,则自动获取用户信息
- 优化了用户体验,确保用户在访问首页时能够及时加载个人相关数据
This commit is contained in:
aixianling
2024-12-23 09:20:05 +08:00
parent a894db0144
commit cf62d2f508

View File

@@ -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 {