From 419712f1bf1e69cd6bda4d0aaa6043207ca7354d Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 9 Feb 2026 02:23:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=90=8E=E9=A1=B5=E9=9D=A2=E5=8D=A1=E5=9C=A8=E5=A4=84?= =?UTF-8?q?=E7=90=86=E4=B8=AD=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/(auth)/login/page.tsx | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsx index 76e7875..9f15454 100644 --- a/app/(auth)/login/page.tsx +++ b/app/(auth)/login/page.tsx @@ -41,6 +41,8 @@ export default function Page() { // 系统通知状态 const [notification, setNotification] = useState<{ enabled: boolean; title: string; content: string } | null>(null); const [showNotification, setShowNotification] = useState(false); + const loginRedirectTimerRef = useRef(null); + const loginRedirectFallbackTimerRef = useRef(null); const iframeRef = useRef(null); @@ -265,29 +267,58 @@ export default function Page() { // 处理登录状态变化 useEffect(() => { + if (loginRedirectTimerRef.current) { + window.clearTimeout(loginRedirectTimerRef.current); + loginRedirectTimerRef.current = null; + } + if (loginRedirectFallbackTimerRef.current) { + window.clearTimeout(loginRedirectFallbackTimerRef.current); + loginRedirectFallbackTimerRef.current = null; + } + if (state.status === "failed") { + setIsSuccessful(false); setIsHandlingToken(false); toast({ type: "error", description: "邮箱或密码不正确", }); } else if (state.status === "invalid_data") { + setIsSuccessful(false); setIsHandlingToken(false); toast({ type: "error", description: "提交的信息校验失败", }); } else if (state.status === "success") { + toast({ type: "success", description: "登录成功,正在进入首页" }); setIsSuccessful(true); - window.location.href = "/"; + loginRedirectTimerRef.current = window.setTimeout(() => { + window.location.replace("/"); + }, 120); + loginRedirectFallbackTimerRef.current = window.setTimeout(() => { + window.location.assign("/"); + }, 1600); } }, [state.status]); const handleSubmit = (formData: FormData) => { + setIsSuccessful(false); setEmail(formData.get("email") as string); formAction(formData); }; + useEffect(() => { + return () => { + if (loginRedirectTimerRef.current) { + window.clearTimeout(loginRedirectTimerRef.current); + } + if (loginRedirectFallbackTimerRef.current) { + window.clearTimeout(loginRedirectFallbackTimerRef.current); + } + }; + }, []); + // 根据组织名称启动钉钉登录(在 iframe 中打开) const startDingTalkLoginForOrg = (orgName: string) => { // 清除 URL 中的 token 参数,避免干扰