添加密码登录&调整接口数据展示&配置底部导航跳转

This commit is contained in:
Eamon-meng
2025-07-01 11:32:37 +08:00
parent b096e20fcd
commit bae4ee9b92
9 changed files with 175 additions and 92 deletions

View File

@@ -324,7 +324,16 @@ function PasswordForm(props: {
type Schema = z.infer<typeof schema>
const form = useForm<Schema>({
resolver: zodResolver(schema),
resolver: zodResolver(
schema.refine(
data =>
/^(?=.*[a-z])(?=.*[A-Z]).{6,}$/.test(data.password),
{
message: '密码需包含大小写字母且不少于6位',
path: ['password'],
},
),
),
defaultValues: {
phone: '',
captcha: '',
@@ -333,6 +342,7 @@ function PasswordForm(props: {
confirm_password: '',
},
})
const router = useRouter()
const handler = form.handleSubmit(async (value) => {
try {
const resp = await updatePassword({
@@ -344,8 +354,10 @@ function PasswordForm(props: {
throw new Error(resp.message)
}
toast.success(`保存成功`)
toast.success(`保存成功,请重新登录`)
setOpen(false)
// 立即跳转到登录页
router.replace('/login')
}
catch (e) {
console.error(e)