import React, { useState, useEffect } from 'react'; import { X, Gift } from 'lucide-react'; import { Language } from '../types'; import { TRANSLATIONS } from '../constants/translations'; interface ExitIntentModalProps { language: Language; onClose: () => void; } export const ExitIntentModal: React.FC = ({ language, onClose }) => { const [isVisible, setIsVisible] = useState(false); const t = TRANSLATIONS[language]; useEffect(() => { // Only run on desktop where mouse leaves viewport if (window.innerWidth < 768) return; const handleMouseLeave = (e: MouseEvent) => { if (e.clientY <= 0) { // User moved mouse to top of browser (tabs/close button) const hasShown = localStorage.getItem('exit_intent_shown'); if (!hasShown) { setIsVisible(true); localStorage.setItem('exit_intent_shown', 'true'); } } }; document.addEventListener('mouseleave', handleMouseLeave); return () => document.removeEventListener('mouseleave', handleMouseLeave); }, []); if (!isVisible) return null; const handleClose = () => { setIsVisible(false); onClose(); }; return (

等一下!

现在离开就错过了 500元 现金抵用券!
仅限今日,留下联系方式即可领取。

); };