diff --git a/src/components/RequireAuth.tsx b/src/components/RequireAuth.tsx index f8f75bfb..b853ff63 100644 --- a/src/components/RequireAuth.tsx +++ b/src/components/RequireAuth.tsx @@ -26,11 +26,6 @@ const RequireAuth: FC = ({ children, redirectTo = "/login" }) => { if (checkingInitialized || !loginConfigSuccess) return ; // 未初始化 则先走setup 流程 if (!initialized) return ; - // 开启guest 并且没token 而且是允许guest访问的路由 则先去过渡页登录 - if (loginConfig?.guest && !token && allowGuest) return ; - // 登陆者是guest,并且不允许访问 - if (token && guest && !allowGuest) return ; - // console.log("authhhhh", allowGuest, token, guest); if (!token) { // 记录下当前的路径,登录后跳转回来 const ignorePath = `/setting/my_account`; @@ -40,6 +35,11 @@ const RequireAuth: FC = ({ children, redirectTo = "/login" }) => { ); return ; } + // 开启guest 并且没token 而且是允许guest访问的路由 则先去过渡页登录 + if (loginConfig?.guest && !token && allowGuest) return ; + // 登陆者是guest,并且不允许访问 + if (token && guest && !allowGuest) return ; + // console.log("authhhhh", allowGuest, token, guest); const tryPath = localStorage.getItem(KEY_LOCAL_TRY_PATH); if (tryPath) { localStorage.removeItem(KEY_LOCAL_TRY_PATH);