import { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Loader2, ArrowRight, Command, ShieldCheck } from 'lucide-react'; import { useAuth } from '../context/AuthContext'; import { cn } from '../lib/utils'; export default function AuthOverlay() { const { isAuthenticated, login } = useAuth(); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [isSubmitting, setIsSubmitting] = useState(false); const handleLogin = async (e) => { e.preventDefault(); if (!password) return; setIsSubmitting(true); setError(''); await new Promise(resolve => setTimeout(resolve, 600)); const result = await login(password); if (!result.success) { setError(result.error); setPassword(''); } setIsSubmitting(false); }; if (isAuthenticated) return null; return (
请输入访问密码