'use client' import { signIn } from "next-auth/react" import { useState } from "react" import { useRouter } from "next/navigation" export default function LoginPage() { const [username, setUsername] = useState("") const [password, setPassword] = useState("") const [error, setError] = useState("") const [loading, setLoading] = useState(false) const router = useRouter() const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() setLoading(true) setError("") try { const result = await signIn("credentials", { username, password, redirect: false, }) if (result?.error) { setError("用户名或密码错误") } else { router.push("/admin") } } catch (err) { setError("登录失败,请稍后重试") } finally { setLoading(false) } } return (
A

后台管理

登录以管理智能体广场

{error && (
{error}
)}
setUsername(e.target.value)} className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" placeholder="请输入用户名" />
setPassword(e.target.value)} className="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent" placeholder="请输入密码" />
默认账号: admin / admin123
) }