import { useEffect } from "react"; import { AlertCircle, CheckCircle, Info, X } from "lucide-react"; /** * 通用消息弹窗 * type: success / error / info */ export default function Modal({ type = "info", title, children, onClose }) { useEffect(() => { const onKey = (e) => { if (e.key === "Escape") onClose?.(); }; document.addEventListener("keydown", onKey); return () => document.removeEventListener("keydown", onKey); }, [onClose]); const styles = { success: { icon: , border: "border-green-500/40", iconBg: "bg-green-500/15" }, error: { icon: , border: "border-red-500/40", iconBg: "bg-red-500/15" }, info: { icon: , border: "border-blue-500/40", iconBg: "bg-blue-500/15" }, }[type] || {}; return (
e.stopPropagation()} >
{styles.icon}

{title}

{children}
); }