"use client"; import { useState } from 'react'; import { useRouter } from 'next/navigation'; import { Lock, User, ArrowRight, AlertCircle, Loader2 } from 'lucide-react'; export default function LoginPage() { const router = useRouter(); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(null); try { const response = await fetch('/api/auth/login', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ username, password }), }); const data = await response.json(); if (response.ok) { router.push('/'); router.refresh(); } else { setError(data.error || '登录失败'); } } catch (err) { setError('网络错误,请稍后重试'); } finally { setLoading(false); } }; return (

系统登录

请输入您的管理员凭证以继续

{error && (

{error}

)}
setUsername(e.target.value)} className="block w-full pl-10 pr-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg leading-5 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm transition-colors" placeholder="请输入用户名" />
setPassword(e.target.value)} className="block w-full pl-10 pr-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg leading-5 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 sm:text-sm transition-colors" placeholder="请输入密码" />

© {new Date().getFullYear()} WinUpdate Neo. All rights reserved.

); }