update: reset captcha after submission

This commit is contained in:
Tony Yang
2025-04-15 15:03:56 +08:00
parent 1b60b3517d
commit 2ec8167b73
5 changed files with 26 additions and 1 deletions
+5
View File
@@ -10,6 +10,8 @@ const hcaptchaResponse = ref('');
const authStore = useAuthStore();
const hcaptchaRef = ref(null);
const handleHcaptchaVerify = (token) => {
hcaptchaResponse.value = token;
};
@@ -24,6 +26,7 @@ const generateMotto = async () => {
try {
const generatedMotto = await generateMottoApi(authStore.jwt, hcaptchaResponse.value);
motto.value = generatedMotto;
hcaptchaRef.value.reset();
} catch (error) {
console.error(error);
alert('Failed to generate motto.');
@@ -39,9 +42,11 @@ const generateMotto = async () => {
<div class="ts-header is-large is-center-aligned">每日金句生成器</div>
<p class="ts-text">Powered By Cloudflare Workers AI</p>
<VueHcaptcha
ref="hcaptchaRef"
:sitekey="$hcaptchaSitekey"
@verify="handleHcaptchaVerify"
@expired="handleHcaptchaExpired"
@reset="handleHcaptchaExpired"
/>
<button class="ts-button" @click="generateMotto" :disabled="!hcaptchaResponse">生成</button>
<p class="ts-text">每日金句:</p>