From 7a1af795efa00dc7ec94f677e4145cf49af5ce22 Mon Sep 17 00:00:00 2001 From: Snowykami Date: Wed, 10 Sep 2025 21:52:25 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=20Promise=20=E5=A4=84=E7=90=86=E7=99=BB=E5=BD=95=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=EF=BC=8C=E6=8F=90=E5=8D=87=E4=BB=A3=E7=A0=81=E5=8F=AF?= =?UTF-8?q?=E8=AF=BB=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/login/login-form.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/web/src/components/login/login-form.tsx b/web/src/components/login/login-form.tsx index b32204f..0732420 100644 --- a/web/src/components/login/login-form.tsx +++ b/web/src/components/login/login-form.tsx @@ -63,14 +63,19 @@ export function LoginForm({ }, [refreshCaptchaKey]) const handleLogin = async (e: React.FormEvent) => { + setIsLogging(true) e.preventDefault() - try { - const res = await userLogin({ username, password, captcha: captchaToken || "" }) - console.log("Login successful:", res) - router.push(redirectBack) - } catch (error) { - console.error("Login failed:", error) - } + userLogin({ username, password, captcha: captchaToken || "" }) + .then(res => { + console.log("Login successful:", res) + router.push(redirectBack) + }) + .catch(error => { + console.error("Login failed:", error) + }) + .finally(() => { + setIsLogging(false) + }) } const handleCaptchaError = (error: string) => {