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