登录增加验证码切换

This commit is contained in:
2026-04-04 00:04:37 +08:00
parent ae3ac9b819
commit a4980df3f1
2 changed files with 12 additions and 2 deletions

View File

@@ -91,6 +91,11 @@ const refreshCaptcha = async () => {
}
}
// 暴露方法给父组件
defineExpose({
refreshCaptcha
})
const handleLogin = async () => {
if (!isFormComplete.value || loading.value) return

View File

@@ -40,10 +40,10 @@
</div>
<!-- 登录表单 -->
<LoginForm v-if="isLogin" @success="onLoginSuccess" />
<LoginForm v-show="isLogin" ref="loginFormRef" @success="onLoginSuccess" />
<!-- 注册表单 -->
<RegisterForm v-else @success="onRegisterSuccess" />
<RegisterForm v-show="!isLogin" @success="onRegisterSuccess" />
<!-- 底部切换 -->
<div class="card-footer">
@@ -70,6 +70,7 @@ const router = useRouter()
const userStore = useUserStore()
const isLogin = ref(true)
const loginFormRef = ref(null)
const storageLimitGb = ref(50)
const storageLimitText = computed(() => {
@@ -95,6 +96,10 @@ onMounted(() => {
const toggleMode = () => {
isLogin.value = !isLogin.value
// 切换到登录时刷新验证码
if (isLogin.value && loginFormRef.value) {
loginFormRef.value.refreshCaptcha()
}
}
const onLoginSuccess = (data) => {