chore: remove comments

This commit is contained in:
Tristan Yang
2022-09-02 21:28:37 +08:00
parent 0c431f325a
commit 9b52b4423f
11 changed files with 6 additions and 23 deletions
+1 -2
View File
@@ -13,14 +13,12 @@ const GuestAllows = GuestRoutes.map((path) => {
return { path };
});
const RequireAuth: FC<Props> = ({ children, redirectTo = "/login" }) => {
// GuestRoutes
const location = useLocation();
const matchs = matchRoutes(GuestAllows, location);
const allowGuest = matchs ? !!matchs[0].pathname : false;
const { data: loginConfig, isLoading: fetchingLoginConfig } = useGetLoginConfigQuery();
const { isLoading: checkingInitial } = useGetInitializedQuery();
const { token, guest, initialized } = useAppSelector((store) => store.authData);
// console.log("authhhhh", allowGuest);
// 初始化和login配置检查
if (checkingInitial || fetchingLoginConfig) return null;
@@ -30,6 +28,7 @@ const RequireAuth: FC<Props> = ({ children, redirectTo = "/login" }) => {
if (loginConfig?.guest && !token && allowGuest) return <Navigate to={"/guest_login"} replace />;
// 登陆者是guest,并且不允许访问
if (token && guest && !allowGuest) return <Navigate to={"/"} replace />;
// console.log("authhhhh", allowGuest, token, guest);
return token ? children : <Navigate to={redirectTo} replace />;
};