first commit

This commit is contained in:
2026-03-10 11:45:54 +08:00
commit e06d464a74
231 changed files with 15232 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
import { useState } from 'react';
import { useNavigate, Link } from 'react-router-dom';
import { Card, Input, Button, Form, toast } from '@heroui/react';
import { signUp } from '../../lib/auth-client';
export default function RegisterPage() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [loading, setLoading] = useState(false);
const navigate = useNavigate();
const handleRegister = async (e: React.FormEvent) => {
e.preventDefault();
setLoading(true);
try {
await signUp.email({
email,
password,
name: email.split('@')[0], // Default name
}, {
onSuccess: () => {
navigate('/');
},
onError: (ctx) => {
toast.danger(ctx.error.message);
}
});
} catch (err) {
console.error(err);
} finally {
setLoading(false);
}
};
return (
<div className="flex items-center justify-center min-h-screen p-4">
<Card className="w-full max-w-md p-6">
<h1 className="text-2xl font-bold mb-6 text-center"> HLAE </h1>
<Form validationBehavior="native" onSubmit={handleRegister} className="flex flex-col gap-4">
<Input
isRequired
label="邮箱"
placeholder="请输入您的邮箱"
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
/>
<Input
isRequired
label="密码"
placeholder="请输入您的密码"
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
/>
<Button color="primary" type="submit" isLoading={loading}>
</Button>
<div className="text-center text-sm">
<Link to="/login" className="text-primary hover:underline"></Link>
</div>
</Form>
</Card>
</div>
);
}