"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; export default function RegisterPage() { const router = useRouter(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [discordId, setDiscordId] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(""); try { const r = await fetch("/api/auth/register", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ email, password, discord_id: discordId || undefined }), }); const data = await r.json(); if (!r.ok) { setError(data.detail || "注册失败"); return; } router.push("/login?registered=1"); } catch { setError("网络错误,请重试"); } finally { setLoading(false); } }; return (
注册后可接收套利信号推送
已有账号?登录