feat: 게임 시작/다운로드 버튼 통합
All checks were successful
Client CI/CD / deploy (push) Successful in 11s

- 단일 "게임 시작" 버튼으로 통합
- 런처 설치 시 게임 실행, 미설치 시 자동 다운로드 (blur 감지)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-24 22:48:47 +09:00
parent 4ec4f9a0a3
commit e496de7e56
2 changed files with 33 additions and 40 deletions

View File

@@ -7,6 +7,7 @@ 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();
@@ -16,19 +17,30 @@ export default function DownloadSection() {
.catch(() => setReady(true));
}, []);
const handleDownload = (e) => {
if (!user) {
e.preventDefault();
navigate('/login');
}
};
const handleLaunch = () => {
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?.url) {
// 런처 미설치 → 자동 다운로드
const a = document.createElement('a');
a.href = info.url;
a.download = '';
a.click();
}
}, 2000);
};
if (!ready) return null;
@@ -36,20 +48,17 @@ export default function DownloadSection() {
return (
<section className="download-section">
<div className="download-content">
<h2 className="download-title">게임 런처 다운로드</h2>
<h2 className="download-title">A301</h2>
{info ? (
<>
<p className="download-meta">
{info.fileName} &middot; {info.fileSize} &middot; {info.version}
{info.version} &middot; {info.fileSize}
</p>
<a href={info.url} download onClick={handleDownload} className="btn-download">
{user ? '다운로드' : '로그인 후 다운로드'}
</a>
<button onClick={handleLaunch} className="btn-launch">
게임 시작
<button onClick={handlePlay} className="btn-play" disabled={launching}>
{launching ? '실행 중...' : '게임 시작'}
</button>
<p className="launch-hint">
게임 시작이 되나요? 먼저 다운로드 launcher.exe install을 실행해주세요.
처음 설치하는 경우 자동으로 다운로드됩니다
</p>
</>
) : (