feat: 本次提交更新内容如下

修正完成
This commit is contained in:
笔记本里的永平
2025-07-11 11:31:48 +08:00
parent 3f43b6d388
commit 8fd9269bef
3 changed files with 25 additions and 47 deletions

View File

@@ -32,6 +32,17 @@ export default function Login() {
const { toast } = useToast();
const { login } = useAuth();
// 检查URL是否为登录页面
const isLoginPage = (url: string) => {
try {
const urlObj = new URL(url, window.location.origin);
return urlObj.pathname === '/login' || urlObj.pathname.endsWith('/login');
} catch {
// 如果URL格式不正确返回false
return false;
}
};
// 倒计时效果
useEffect(() => {
if (countdown > 0) {
@@ -132,7 +143,13 @@ export default function Login() {
// 跳转到首页或重定向URL
const returnUrl = searchParams.get('returnUrl');
if (returnUrl) {
navigate(decodeURIComponent(returnUrl));
const decodedUrl = decodeURIComponent(returnUrl);
// 检查重定向URL是否为登录页面避免无限重定向
if (isLoginPage(decodedUrl)) {
navigate('/');
} else {
window.location.href = decodedUrl;
}
} else {
navigate('/');
}
@@ -164,7 +181,13 @@ export default function Login() {
// 跳转到首页或重定向URL
const returnUrl = searchParams.get('returnUrl');
if (returnUrl) {
navigate(decodeURIComponent(returnUrl));
const decodedUrl = decodeURIComponent(returnUrl);
// 检查重定向URL是否为登录页面避免无限重定向
if (isLoginPage(decodedUrl)) {
navigate('/');
} else {
window.location.href = decodedUrl;
}
} else {
navigate('/');
}