mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
feat(projects): get user info in router guard and remove in localStorage. close #459
This commit is contained in:
@ -92,6 +92,7 @@ export function createRouteGuard(router: Router) {
|
||||
* @param to to route
|
||||
*/
|
||||
async function initRoute(to: RouteLocationNormalized): Promise<RouteLocationRaw | null> {
|
||||
const authStore = useAuthStore();
|
||||
const routeStore = useRouteStore();
|
||||
|
||||
const notFoundRoute: RouteKey = 'not-found';
|
||||
@ -125,6 +126,9 @@ async function initRoute(to: RouteLocationNormalized): Promise<RouteLocationRaw
|
||||
// the auth route is initialized
|
||||
// it is not the "not-found" route, then it is allowed to access
|
||||
if (routeStore.isInitAuthRoute && !isNotFoundRoute) {
|
||||
// update user info
|
||||
await authStore.updateUserInfo();
|
||||
|
||||
return null;
|
||||
}
|
||||
// it is captured by the "not-found" route, then check whether the route exists
|
||||
|
Reference in New Issue
Block a user