From 03051c6a8f216e1488e156fc0f2f2dc8298911fa Mon Sep 17 00:00:00 2001 From: zhaojisen <1301338853@qq.com> Date: Mon, 17 Jun 2024 19:11:34 +0800 Subject: [PATCH] fixed: Fixed an issue where the countdown stopped at 2 seconds --- .../Apps/UserConfirmDialog/index.vue | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/Apps/UserConfirmDialog/index.vue b/src/components/Apps/UserConfirmDialog/index.vue index 8b09c06f3..8c2b53a0b 100644 --- a/src/components/Apps/UserConfirmDialog/index.vue +++ b/src/components/Apps/UserConfirmDialog/index.vue @@ -50,7 +50,7 @@ - + @@ -175,18 +175,20 @@ export default { this.$axios.post(`/api/v1/authentication/mfa/select/`, { type: 'sms' }).then(res => { this.$message.success(this.$tc('VerificationCodeSent')) let time = 60 - const interval = setInterval(() => { - const originText = this.smsBtnText - this.smsBtnText = this.$t('Pending') + `: ${time}` - this.smsBtnDisabled = true - time -= 1 + this.smsBtnDisabled = true - if (time === 0) { - this.smsBtnText = originText - this.smsBtnDisabled = false + const interval = setInterval(() => { + time -= 1 + this.smsBtnText = `${this.$t('Pending')}: ${time}` + + if (time <= 0) { clearInterval(interval) + this.smsBtnText = this.$t('SendVerificationCode') + this.smsBtnDisabled = false } }, 1000) + }).catch(() => { + this.$message.error(this.$tc('FailedToSendVerificationCode')) }) }, handleConfirm() {