chore: remove comments
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { FC } from "react";
|
||||
import { FC, memo } from "react";
|
||||
import { NavLink } from "react-router-dom";
|
||||
import Tippy from "@tippyjs/react";
|
||||
import IconMessage from "../../../assets/icons/message.svg";
|
||||
@@ -110,4 +110,4 @@ const Profile: FC<Props> = ({ uid, type = "embed", cid }) => {
|
||||
);
|
||||
};
|
||||
|
||||
export default Profile;
|
||||
export default memo(Profile);
|
||||
|
||||
@@ -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 />;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user