import { Navigate, Route, Routes } from "react-router-dom";
import Login from "../pages/Login";
import ResetPassword from "../pages/ResetPassword";
import AppLayout from "../layouts/AppLayout";
import { menuRoutes, extraRoutes } from "./routes";
import { useAuth } from "../hooks/useAuth";
function RequireAuth({ children }: { children: JSX.Element }) {
const { isAuthed, profile } = useAuth();
if (!isAuthed) {
return ;
}
// 强制改密拦截
if (profile?.pwdResetRequired === 1) {
return ;
}
return children;
}
export default function AppRoutes() {
return (
} />
} />
}
>
{menuRoutes.map((route) => (
))}
{extraRoutes && extraRoutes.map((route) => (
))}
} />
);
}