fix(static): 获取邮箱验证码后保留已输入的图形验证码
refreshCaptcha 增加 preserveInput 参数,获取验证码后的自动刷新不再清空图形验证码输入框,避免误清空用户输入
This commit is contained in:
1 parent
02904f711e
commit
37c50ed517
2 files changed
+10
-8
No files matched your search
@@ -63,11 +63,11 @@ let cooldownTimer = null; // 重发倒计时(与服务端 smtp 同邮箱 60s
|
||||
let captchaToken = '';
|
||||
let captchaLoading = false; // 防重复点击:加载中忽略再次触发
|
||||
|
||||
async function refreshCaptcha() {
|
||||
async function refreshCaptcha(preserveInput) {
|
||||
if (captchaLoading) return;
|
||||
captchaLoading = true;
|
||||
captchaToken = '';
|
||||
captchaInput.value = ''; // 开始刷新时清空输入,避免用户误用旧验证码
|
||||
if (!preserveInput) captchaInput.value = ''; // 默认清空输入;preserveInput=true 时保留(获取验证码后)
|
||||
captchaImg.style.opacity = '0.5'; // 视觉提示:正在刷新
|
||||
try {
|
||||
const res = await fetch('/captcha/image', { cache: 'no-store' });
|
||||
@@ -267,8 +267,9 @@ getCodeButton.addEventListener('click', async function () {
|
||||
codeTip.classList.add('tip-red');
|
||||
if (httpStatus === 429) startResendCooldown(60); // 命中冷却/限流,倒计时对齐
|
||||
} finally {
|
||||
// CAPTCHA Token 一次性消费,无论成败都刷新
|
||||
refreshCaptcha();
|
||||
// CAPTCHA Token 一次性消费,无论成败都刷新图形验证码;
|
||||
// 刷新时保留已输入的图形验证码答案,避免误清空用户输入
|
||||
refreshCaptcha(true);
|
||||
if (!cooldownTimer) getCodeButton.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,11 +19,11 @@ let cooldownTimer = null; // 重发倒计时(与服务端同邮箱 60s 发送
|
||||
let captchaToken = '';
|
||||
let captchaLoading = false; // 防重复点击:加载中忽略再次触发
|
||||
|
||||
async function refreshCaptcha() {
|
||||
async function refreshCaptcha(preserveInput) {
|
||||
if (captchaLoading) return;
|
||||
captchaLoading = true;
|
||||
captchaToken = '';
|
||||
captchaInput.value = ''; // 开始刷新时清空输入,避免用户误用旧验证码
|
||||
if (!preserveInput) captchaInput.value = ''; // 默认清空输入;preserveInput=true 时保留(获取验证码后)
|
||||
captchaImg.style.opacity = '0.5'; // 视觉提示:正在刷新
|
||||
try {
|
||||
const res = await fetch('/captcha/image', { cache: 'no-store' });
|
||||
@@ -222,8 +222,9 @@ getCodeButton.addEventListener('click', async function () {
|
||||
codeTip.classList.add('tip-red');
|
||||
if (httpStatus === 429) startResendCooldown(60); // 命中冷却/限流,倒计时对齐
|
||||
} finally {
|
||||
// CAPTCHA Token 一次性消费,无论成败都刷新
|
||||
refreshCaptcha();
|
||||
// CAPTCHA Token 一次性消费,无论成败都刷新图形验证码;
|
||||
// 刷新时保留已输入的图形验证码答案,避免误清空用户输入
|
||||
refreshCaptcha(true);
|
||||
if (!cooldownTimer) getCodeButton.disabled = false;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user