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
@@ -15,6 +15,8 @@ const props = defineProps({
const authStore = useAuthStore();
const router = useRouter();
const hcaptchaRef = ref(null);
const avatarFile = ref(null);
const avatarError = ref('');
const hcaptchaResponse = ref('');
@@ -57,6 +59,7 @@ const onSubmit = async () => {
try {
await uploadAvatar(avatarFile.value, authStore.jwt, hcaptchaResponse.value);
alert('Avatar uploaded successfully!');
hcaptchaRef.value.reset();
// After successful upload, reload this page
router.go(0);
} catch (error) {
@@ -101,9 +104,11 @@ const avatarUrl = computed(() => {
</div>
</div>
<VueHcaptcha
ref="hcaptchaRef"
:sitekey="$hcaptchaSitekey"
@verify="handleHcaptchaVerify"
@expired="handleHcaptchaExpired"
@reset="handleHcaptchaExpired"
/>
<div class="ts-wrap has-top-spaced is-end-aligned">
<button class="ts-button" :disabled="!(avatarFile && avatarError === '' && hcaptchaResponse)" type="submit">更新</button>