"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 { authClient } from "@/lib/auth-client"; export default function LoginPage() { const router = useRouter(); const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(""); setLoading(true); try { const res = await authClient.signIn.username({ username, password, fetchOptions: { credentials: "include" }, }); if (res.error) { setError(res.error.message ?? "登录失败,请检查用户名和密码"); } else { router.push("/dashboard"); router.refresh(); } } catch { setError("网络错误,请稍后重试"); } finally { setLoading(false); } }; return (
{/* Brand */}

Helios EVCS

电动车充电站管理系统

setUsername(e.target.value)} /> setPassword(e.target.value)} /> {error && ( 登录失败 {error} setError("")} /> )}

OCPP 1.6-J Protocol • v0.1.0

); }