/** * Admin 后台 - 登录页(报刊风) * * 密码验证通过后由服务端写入 HttpOnly 会话 Cookie。 */ import { useState } from 'react' import { ApiError, login } from './api' export default function Login({ onSuccess }: { onSuccess: () => void }) { const [password, setPassword] = useState('') const [submitting, setSubmitting] = useState(false) const [error, setError] = useState('') async function handleSubmit(e: React.FormEvent) { e.preventDefault() if (!password || submitting) return setSubmitting(true) setError('') try { await login(password) onSuccess() } catch (err) { setError( err instanceof ApiError ? err.message.split('\n')[0] : '登录失败,请检查网络连接', ) } finally { setSubmitting(false) } } return (
管理后台 · 管理员登录