添加密码登录&调整接口数据展示&配置底部导航跳转
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user