From f157130b2340fd963249192e0873b4fcd3038d33 Mon Sep 17 00:00:00 2001 From: weiran <32252943+weirantongxue@users.noreply.github.com> Date: Fri, 13 Dec 2024 10:52:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=AA=8C=E8=AF=81=E7=A0=81=E8=BF=87?= =?UTF-8?q?=E6=9C=9F=E6=97=B6=E9=97=B4=E5=AF=B9=E6=AF=94=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=97=B6=E9=97=B4=20(#39)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 针对登录验证码过期问题,原因为获取本地时间导致验证码提前失效。现已更正为采用服务器时间进行验证,确保验证码有效期内正常使用。 --- src/views/login/components/account/index.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/views/login/components/account/index.vue b/src/views/login/components/account/index.vue index af9a88ff..e6693d24 100644 --- a/src/views/login/components/account/index.vue +++ b/src/views/login/components/account/index.vue @@ -72,11 +72,11 @@ const rules: FormInstance['rules'] = { // 验证码过期定时器 let timer -const startTimer = (expireTime: number) => { +const startTimer = (expireTime: number, curTime = Date.now()) => { if (timer) { clearTimeout(timer) } - const remainingTime = expireTime - Date.now() + const remainingTime = expireTime - curTime if (remainingTime <= 0) { form.expired = true return @@ -100,7 +100,7 @@ const getCaptcha = () => { captchaImgBase64.value = img form.uuid = uuid form.expired = false - startTimer(expireTime) + startTimer(expireTime, Number(res.timestamp)) }) }