Feat: If the user is not logged in, jump to the login page by refreshing. (#5451)

### What problem does this PR solve?

Feat: If the user is not logged in, jump to the login page by
refreshing.
### Type of change


- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2025-02-27 18:48:53 +08:00
committed by GitHub
parent 83d0949498
commit 8b2c04abc4
7 changed files with 15 additions and 10 deletions

View File

@ -1,12 +1,13 @@
import { useAuth } from '@/hooks/auth-hooks';
import { Navigate, Outlet } from 'umi';
import { redirectToLogin } from '@/utils/authorization-util';
import { Outlet } from 'umi';
export default () => {
const { isLogin } = useAuth();
if (isLogin === true) {
return <Outlet />;
} else if (isLogin === false) {
return <Navigate to="/login" />;
redirectToLogin();
}
return <></>;