所有模块添加路由守卫

This commit is contained in:
2026-08-27 16:46:52 +08:00
parent 989120cab8
commit cd5a385cda
4 changed files with 55 additions and 20 deletions
-8
View File
@@ -24,14 +24,6 @@ export default function HomePage() {
const [searchParams] = useSearchParams();
const [userInfo, setUserInfo] = useState<SessionUserInfo | null>(() => getUserInfo());
// 登录守卫:未登录跳转 /login
useEffect(() => {
const token = sessionStorage.getItem('userToken');
if (!token) {
navigate('/login', { replace: true });
}
}, [navigate]);
// 首页模块多时需纵向滚动;离开后恢复全局 overflow:hidden(其他模块自管布局)
useEffect(() => {
document.body.style.overflow = 'auto';