Skip to content

Commit

Permalink
fix: 验证码过期时间对比改为服务器时间 (#39)
Browse files Browse the repository at this point in the history
针对登录验证码过期问题,原因为获取本地时间导致验证码提前失效。现已更正为采用服务器时间进行验证,确保验证码有效期内正常使用。
  • Loading branch information
weirantongxue authored Dec 13, 2024
1 parent 030dede commit f157130
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/views/login/components/account/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -100,7 +100,7 @@ const getCaptcha = () => {
captchaImgBase64.value = img
form.uuid = uuid
form.expired = false
startTimer(expireTime)
startTimer(expireTime, Number(res.timestamp))
})
}
Expand Down

0 comments on commit f157130

Please sign in to comment.