From f1853b8fab7a9585ddb5488b724fbc40d70cd409 Mon Sep 17 00:00:00 2001 From: npmrun <1549469775@qq.com> Date: Fri, 15 May 2026 14:14:45 +0800 Subject: [PATCH] fix: add double-submission guard, captcha ARIA labels, and error handling on mount - Guard onSubmit against concurrent calls via loading flag - Add role="img" and aria-label to captcha SVG container for accessibility - Wrap initial captcha fetch in try/catch to show error toast on failure Co-Authored-By: Claude Opus 4.7 --- app/pages/register.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/pages/register.vue b/app/pages/register.vue index 0c38d40..4d7b0f8 100644 --- a/app/pages/register.vue +++ b/app/pages/register.vue @@ -34,6 +34,7 @@ async function fetchCaptcha() { } async function onSubmit() { + if (loading.value) return loading.value = true try { const res = await $fetch<{ code: number; message: string; data: unknown }>( @@ -67,7 +68,13 @@ async function onSubmit() { } } -onMounted(fetchCaptcha) +onMounted(async () => { + try { + await fetchCaptcha() + } catch { + toast.add({ title: '验证码加载失败,请刷新页面', color: 'error' }) + } +})