"use client"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { Alert, Button, Card, CloseButton, Input, Label, TextField } from "@heroui/react"; import { Thunderbolt } from "@gravity-ui/icons"; import { api } from "@/lib/api"; export default function SetupPage() { const router = useRouter(); const [form, setForm] = useState({ name: "", email: "", username: "", password: "", confirmPassword: "", }); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const handleChange = (field: keyof typeof form) => (e: React.ChangeEvent) => { setForm((prev) => ({ ...prev, [field]: e.target.value })); }; const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); if (form.password !== form.confirmPassword) { setError("两次输入的密码不一致"); return; } if (form.password.length < 8) { setError("密码长度至少 8 位"); return; } setLoading(true); try { await api.setup.create({ name: form.name, email: form.email, username: form.username, password: form.password, }); router.push("/login?setup=1"); } catch (err) { setError(err instanceof Error ? err.message : "初始化失败,请重试"); } finally { setLoading(false); } }; return (
{/* Brand */}

Helios EVCS

首次启动 · 创建管理员账号

{error && ( 初始化失败 {error} setError("")} /> )}

此页面仅在首次启动时可访问

); }