feat: 添加用户设置功能,支持修改昵称和邮箱,重构相关路由和组件
This commit is contained in:
@@ -2,10 +2,9 @@
|
||||
import type { GenericObject } from "vee-validate";
|
||||
import type { EmailVerifyClient } from "@/api/types";
|
||||
import { toastController } from "@ionic/vue";
|
||||
import { toTypedSchema } from "@vee-validate/yup";
|
||||
import { Field, Form } from "vee-validate";
|
||||
import * as yup from "yup";
|
||||
import { authClient } from "@/auth";
|
||||
import { authClient, emailSchema } from "@/auth";
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: "submit", value: EmailVerifyClient): void;
|
||||
@@ -22,17 +21,6 @@ const emailError = ref("");
|
||||
|
||||
let timer: number | null = null;
|
||||
|
||||
const schema = computed(() => toTypedSchema(yup.object({
|
||||
email: yup
|
||||
.string()
|
||||
.required(t("auth.login.validation.emailRequired"))
|
||||
.email(t("auth.login.validation.emailInvalid")),
|
||||
otp: yup
|
||||
.string()
|
||||
.required(t("auth.login.validation.otpRequired"))
|
||||
.matches(/^\d{6}$/, t("auth.login.validation.otpInvalid")),
|
||||
})));
|
||||
|
||||
function startCountdown() {
|
||||
countdown.value = 60;
|
||||
timer = setInterval(() => {
|
||||
@@ -53,7 +41,6 @@ async function sendOtp() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 使用yup进行验证
|
||||
try {
|
||||
await yup.string().email().validate(emailValue);
|
||||
}
|
||||
@@ -110,7 +97,7 @@ onUnmounted(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Form :validation-schema="schema" class="mt-5" @submit="handleSubmit">
|
||||
<Form :validation-schema="emailSchema" class="mt-5" @submit="handleSubmit">
|
||||
<Field v-slot="{ field, errorMessage }" name="email" type="email">
|
||||
<div class="mb-4">
|
||||
<ui-input
|
||||
|
||||
Reference in New Issue
Block a user