import type { AFormRef } from '@/components/common/ao' import { useRouter } from 'expo-router' import { Lock, UserRound } from 'lucide-react-native' import { useRef, useState } from 'react' import { Image, ScrollView, View } from 'react-native' import { AButton, AForm, AFormItem, AInput } from '@/components/common/ao' import { registerDefaultApi } from '@/request/api/auth' import { toast } from '@/utils/toast' interface RegisterForm { username: string password: string confirmPassword: string } export default function AuthRegister() { const router = useRouter() const scrollRef = useRef(null) const [form, setForm] = useState({ username: '', password: '', confirmPassword: '', }) const [loading, setLoading] = useState(false) const formRef = useRef(null) const handleInputChange = (field: keyof RegisterForm, value: string) => { setForm(prev => ({ ...prev, [field]: value })) } const handleRegister = async () => { if (formRef.current?.validate()) { setLoading(true) await registerDefaultApi({ account: form.username, password: form.password, }).then((res) => { if (res.isSuccess) { console.log(res) toast.show({ title: '注册成功', }) // router.replace('/auth/login') } else { toast.show({ title: res.message || '注册失败', }) } }).catch((_err) => { }).finally(() => { setLoading(false) }) } } return ( handleInputChange('username', text)} /> handleInputChange('password', text)} /> val === form.password, message: '两次密码不一致', }, ]} > handleInputChange('confirmPassword', text)} /> 注册 ) }