feat: 验证码请求限流处理

This commit is contained in:
rd
2025-09-08 17:59:19 +08:00
parent 8597ad67f0
commit 9d150ee292
3 changed files with 35 additions and 12 deletions

View File

@ -103,6 +103,7 @@ const { Link } = Typography;
const { TabPane } = Tabs;
import PuzzleVerification from '../PuzzleVerification.vue';
import SelectAccountModal from '../select-account-modal/index.vue';
import { postClearRateLimiter } from '@/api/all/common';
import { postRegisterCaptcha,postForgetPasswordCaptcha, fetchProfileInfo, postRegister, postForgetPassword } from '@/api/all/login';
import { joinEnterpriseByInviteCode } from '@/api/all';
import { ref, reactive, onUnmounted, computed } from 'vue';
@ -258,28 +259,36 @@ const getCode = async () => {
}
formRef.value.validateFields('mobile').then(() => {
isVerificationVisible.value = true;
getCaptcha();
});
};
// 验证码验证通过后
const handleVerificationSubmit = async () => {
isVerificationVisible.value = false;
startCountdown();
const getCaptcha = async () => {
try {
const fn = isResetPassword.value ? postForgetPasswordCaptcha : postRegisterCaptcha;
const { code, message: msg } = await fn({ mobile: formData.value.mobile });
if (code === 200) {
startCountdown()
message.success(msg);
}
} catch (error) {
// 重置倒计时
countdown.value = 0;
clearInterval(timer.value);
if (error.status === 429) {
isVerificationVisible.value = true;
}
}
};
// 验证码验证通过后
const handleVerificationSubmit = () => {
isVerificationVisible.value = false;
postClearRateLimiter();
getCaptcha();
};
// 获取用户信息
const getProfileInfo = async () => {
const { code, data } = await fetchProfileInfo();