perf: 登录失败时清除验证码状态

This commit is contained in:
xiaojunnuo
2025-09-24 00:06:00 +08:00
parent 2c1600ddfb
commit 1c15beadc7
8 changed files with 130 additions and 58 deletions
@@ -1,5 +1,5 @@
<template>
<component :is="captchaComponent" v-if="settingStore.inited" ref="captchaRef" class="captcha_input" :captcha-get="getCaptcha" @change="onChange" />
<component :is="captchaComponent" v-if="settingStore.inited" ref="captchaRef" :model-value="modelValue" class="captcha_input" :captcha-get="getCaptcha" @change="onChange" />
</template>
<script setup lang="ts">
import { ref, computed, defineAsyncComponent } from "vue";
@@ -7,6 +7,12 @@ import { useSettingStore } from "/@/store/settings";
import { nanoid } from "nanoid";
import { request } from "/@/api/service";
const props = defineProps({
modelValue: {
type: Object,
default: () => ({}),
},
});
const captchaRef = ref(null);
const settingStore = useSettingStore();
@@ -17,7 +23,7 @@ const captchaAddonId = computed(() => {
return settingStore.sysPublic.captchaAddonId ?? 0;
});
const captchaComponent = computed(() => {
let type = "image";
let type: any = "image";
if (settingStore.sysPublic.captchaAddonId && settingStore.sysPublic.captchaType) {
type = settingStore.sysPublic.captchaType;
}
@@ -36,7 +42,7 @@ async function getCaptcha(): Promise<any> {
});
}
function onChange(data) {
function onChange(data: any) {
emits("update:modelValue", data);
emits("change", data);
}
@@ -44,7 +50,11 @@ function onChange(data) {
async function getCaptchaForm() {
return await captchaRef.value.getCaptchaForm();
}
async function reset() {
await captchaRef.value.reset();
}
defineExpose({
getCaptchaForm,
reset,
});
</script>