feat: 本次提交更新内容如下
修正完成
This commit is contained in:
@@ -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('/');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user