import { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../context/useAuth'; import { getDownloadInfo } from '../api/download'; import './DownloadSection.css'; export default function DownloadSection() { const [info, setInfo] = useState(null); const [ready, setReady] = useState(false); const [launching, setLaunching] = useState(false); const { user } = useAuth(); const navigate = useNavigate(); useEffect(() => { getDownloadInfo() .then((data) => { setInfo(data); setReady(true); }) .catch(() => setReady(true)); }, []); const handlePlay = () => { if (!user) { navigate('/login'); return; } setLaunching(true); let launched = false; const onBlur = () => { launched = true; }; window.addEventListener('blur', onBlur); window.location.href = 'a301://launch?token=' + user.token; setTimeout(() => { window.removeEventListener('blur', onBlur); setLaunching(false); if (!launched && info?.launcherUrl) { // 런처 미설치 → launcher.exe 다운로드 const a = document.createElement('a'); a.href = info.launcherUrl; a.download = 'launcher.exe'; a.click(); } }, 2000); }; if (!ready) return null; return (

One of the plans

{info ? ( <>

{info.version} · {info.fileSize}

런처 미설치 시 자동으로 다운로드됩니다. 설치 후 다시 클릭하세요.

) : (

런처 준비 중입니다. 잠시 후 다시 확인해주세요.

)}
); }