feat: 게임 시작 버튼 추가 및 AuthContext 린트 에러 수정
All checks were successful
Client CI/CD / deploy (push) Successful in 10s
All checks were successful
Client CI/CD / deploy (push) Successful in 10s
- DownloadSection에 a301:// 커스텀 URI로 게임 실행하는 버튼 추가 - AuthContext에서 createContext와 useAuth 훅을 별도 파일로 분리하여 react-refresh 린트 에러 해결 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { BrowserRouter, Routes, Route, Navigate, useNavigate, useLocation } from 'react-router-dom';
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { AuthProvider, useAuth } from './context/AuthContext';
|
||||
import { AuthProvider } from './context/AuthContext';
|
||||
import { useAuth } from './context/useAuth';
|
||||
import LoginPage from './pages/LoginPage';
|
||||
import RegisterPage from './pages/RegisterPage';
|
||||
import HomePage from './pages/HomePage';
|
||||
|
||||
@@ -39,6 +39,33 @@
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.btn-launch {
|
||||
display: inline-block;
|
||||
padding: 16px 48px;
|
||||
background: transparent;
|
||||
color: #BACDB0;
|
||||
border: 2px solid #BACDB0;
|
||||
border-radius: 8px;
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s, color 0.2s, transform 0.15s;
|
||||
letter-spacing: 0.05em;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
.btn-launch:hover {
|
||||
background: #BACDB0;
|
||||
color: #2E2C2F;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.launch-hint {
|
||||
font-size: 0.78rem;
|
||||
color: rgba(255, 255, 255, 0.3);
|
||||
margin: 16px 0 0;
|
||||
}
|
||||
|
||||
.download-preparing {
|
||||
font-size: 0.9rem;
|
||||
color: rgba(255, 255, 255, 0.4);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useAuth } from '../context/useAuth';
|
||||
import { getDownloadInfo } from '../api/download';
|
||||
import './DownloadSection.css';
|
||||
|
||||
@@ -23,6 +23,14 @@ export default function DownloadSection() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleLaunch = () => {
|
||||
if (!user) {
|
||||
navigate('/login');
|
||||
return;
|
||||
}
|
||||
window.location.href = 'a301://launch?token=' + user.token;
|
||||
};
|
||||
|
||||
if (!ready) return null;
|
||||
|
||||
return (
|
||||
@@ -37,6 +45,12 @@ export default function DownloadSection() {
|
||||
<a href={info.url} download onClick={handleDownload} className="btn-download">
|
||||
{user ? '다운로드' : '로그인 후 다운로드'}
|
||||
</a>
|
||||
<button onClick={handleLaunch} className="btn-launch">
|
||||
게임 시작
|
||||
</button>
|
||||
<p className="launch-hint">
|
||||
게임 시작이 안 되나요? 먼저 다운로드 후 launcher.exe install을 실행해주세요.
|
||||
</p>
|
||||
</>
|
||||
) : (
|
||||
<p className="download-preparing">런처 준비 중입니다. 잠시 후 다시 확인해주세요.</p>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { createContext, useContext, useState, useCallback, useEffect } from 'react';
|
||||
import { useState, useCallback, useEffect } from 'react';
|
||||
import { login as apiLogin } from '../api/auth';
|
||||
|
||||
const AuthContext = createContext(null);
|
||||
import { AuthContext } from './authContextValue';
|
||||
|
||||
export function AuthProvider({ children }) {
|
||||
const [user, setUser] = useState(() => {
|
||||
@@ -38,8 +37,3 @@ export function AuthProvider({ children }) {
|
||||
);
|
||||
}
|
||||
|
||||
export function useAuth() {
|
||||
const ctx = useContext(AuthContext);
|
||||
if (!ctx) throw new Error('useAuth must be used within AuthProvider');
|
||||
return ctx;
|
||||
}
|
||||
|
||||
3
src/context/authContextValue.js
Normal file
3
src/context/authContextValue.js
Normal file
@@ -0,0 +1,3 @@
|
||||
import { createContext } from 'react';
|
||||
|
||||
export const AuthContext = createContext(null);
|
||||
8
src/context/useAuth.js
Normal file
8
src/context/useAuth.js
Normal file
@@ -0,0 +1,8 @@
|
||||
import { useContext } from 'react';
|
||||
import { AuthContext } from './authContextValue';
|
||||
|
||||
export function useAuth() {
|
||||
const ctx = useContext(AuthContext);
|
||||
if (!ctx) throw new Error('useAuth must be used within AuthProvider');
|
||||
return ctx;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useAuth } from '../context/useAuth';
|
||||
import AnnouncementAdmin from '../components/admin/AnnouncementAdmin';
|
||||
import DownloadAdmin from '../components/admin/DownloadAdmin';
|
||||
import UserAdmin from '../components/admin/UserAdmin';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useAuth } from '../context/useAuth';
|
||||
import DownloadSection from '../components/DownloadSection';
|
||||
import AnnouncementBoard from '../components/AnnouncementBoard';
|
||||
import './HomePage.css';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useState } from 'react';
|
||||
import { useNavigate, Link, useLocation } from 'react-router-dom';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
import { useAuth } from '../context/useAuth';
|
||||
import './LoginPage.css';
|
||||
|
||||
export default function LoginPage() {
|
||||
|
||||
Reference in New Issue
Block a user