From 6e87a6776b55b0fc4fae290bd4e6378519733117 Mon Sep 17 00:00:00 2001 From: al Date: Wed, 4 Dec 2024 16:42:33 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=99=BB=E5=BD=95=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/login/page.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/app/login/page.js b/app/login/page.js index 5da505f..4b23a28 100644 --- a/app/login/page.js +++ b/app/login/page.js @@ -35,6 +35,7 @@ function Login({ handleLogin }) { const [activeIndex, setActiveIndex] = useState(0); const [veriCode, setVeriCode] = useState(""); const [isCounting, setIsCounting] = useState(false); + const [isLoading, setIsLoading] = useState(false); const [seconds, setSeconds] = useState(60); const [deviceType, setDeviceType] = useState(""); const [loginInfo, setLoginInfo] = useState({ @@ -145,6 +146,7 @@ function Login({ handleLogin }) { ...body, veri_code: veriCode, }; + setIsLoading(true); try { const data = await requireAPI( "POST", @@ -155,7 +157,9 @@ function Login({ handleLogin }) { body, } ); + if (data.ret === -1) { + setIsLoading(false); Toast.show({ icon: "fail", content: data.msg, @@ -172,12 +176,14 @@ function Login({ handleLogin }) { } else { save("firstLogin", 0); } + setIsLoading(false); router.push( !data?.data?.is_enabled && type != "password" ? "/my/setting/editPassword?is_enabled=" + data?.data?.is_enabled : "/" ); } catch (error) { + setIsLoading(false); // console.error(error); } }; @@ -349,6 +355,7 @@ function Login({ handleLogin }) { { +const LoginBtn = ({ + loginInfo, + setLoginInfo, + type, + handleSubmit, + isLoading, +}) => { const router = useRouter(); useEffect(() => {}, []); return ( @@ -493,6 +507,7 @@ const LoginBtn = ({ loginInfo, setLoginInfo, type, handleSubmit }) => {