update: reset captcha after submission
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user