M2: 사이트 서버 · 사이트 v1 - gvr.tkrmagid.kr 배포
- site/server: Discord OAuth2 + 봇 토큰 멤버 확인, 세션, 1회용 등록 코드·기기 키 인증, 게임 PC WebSocket 중계(JSON·음성 바이너리), 15초 무응답 잠금, 게임 이미지 캐시, 관리 CLI - site/web: 타임라인·따라 읽기 재생(단어 강조·이어듣기·현장 모드·재생 게인)·필터·검색·실시간·교정, 발로란트/롤 경기 상세, 잠금 화면(관리자 등록 코드), 모바일, 효과음 - deploy/site: Dockerfile·compose·deploy.sh·make-env.sh (.5, 포트 2972) - 앱 코어: 사이트 필터 묶음(킬·라운드)과 유저 필터 규칙 맞춤, hello 에 서버 ID Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
113
site/web/src/App.tsx
Normal file
113
site/web/src/App.tsx
Normal file
@@ -0,0 +1,113 @@
|
||||
import { useEffect } from 'react';
|
||||
import { Navigate, Route, Routes } from 'react-router';
|
||||
import { MotionConfig } from 'framer-motion';
|
||||
import { AuthProvider, DataProvider, StatusProvider, useAuth, useStatus } from './store/app';
|
||||
import { useReducedMotion } from './store/settings';
|
||||
import { player } from './store/player';
|
||||
import { resumeAudio } from './lib/audio';
|
||||
import { Header } from './components/Header';
|
||||
import { LockOverlay } from './components/LockOverlay';
|
||||
import { LoginPage } from './components/LoginPage';
|
||||
import { PlayerBar } from './components/PlayerBar';
|
||||
import { Spinner } from './components/common';
|
||||
import { TimelinePage } from './pages/TimelinePage';
|
||||
import { MatchPage } from './pages/MatchPage';
|
||||
import { MatchesPage, UserPage, UsersPage } from './pages/UserPages';
|
||||
|
||||
/** Space 재생/일시정지 · ←/→ 이전/다음 발화 · / 검색 */
|
||||
function useShortcuts() {
|
||||
useEffect(() => {
|
||||
const onKey = (e: KeyboardEvent) => {
|
||||
const t = e.target as HTMLElement;
|
||||
const typing = t.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(t.tagName);
|
||||
if (e.ctrlKey || e.metaKey || e.altKey) return;
|
||||
if (e.key === '/' && !typing) {
|
||||
e.preventDefault();
|
||||
document.getElementById('gvr-search')?.focus();
|
||||
return;
|
||||
}
|
||||
if (typing) return;
|
||||
if (e.key === ' ' || e.code === 'Space') {
|
||||
if (t.tagName === 'BUTTON' || t.tagName === 'A') t.blur();
|
||||
e.preventDefault();
|
||||
player.toggle();
|
||||
} else if (e.key === 'ArrowRight') {
|
||||
e.preventDefault();
|
||||
player.next();
|
||||
} else if (e.key === 'ArrowLeft') {
|
||||
e.preventDefault();
|
||||
player.prev();
|
||||
}
|
||||
};
|
||||
window.addEventListener('keydown', onKey);
|
||||
// 첫 사용자 제스처에서 AudioContext 를 깨워 효과음이 바로 나게
|
||||
const wake = () => resumeAudio();
|
||||
window.addEventListener('pointerdown', wake, { once: true });
|
||||
return () => {
|
||||
window.removeEventListener('keydown', onKey);
|
||||
window.removeEventListener('pointerdown', wake);
|
||||
};
|
||||
}, []);
|
||||
}
|
||||
|
||||
function Shell() {
|
||||
const { locked, epoch } = useStatus();
|
||||
useShortcuts();
|
||||
return (
|
||||
<div className={`shell${locked ? ' is-locked' : ''}`}>
|
||||
<div className="app" aria-hidden={locked || undefined}>
|
||||
<Header />
|
||||
<div className="content" key={epoch}>
|
||||
<Routes>
|
||||
<Route path="/" element={<TimelinePage />} />
|
||||
<Route path="/matches" element={<MatchesPage />} />
|
||||
<Route path="/matches/:id" element={<MatchPage />} />
|
||||
<Route path="/users" element={<UsersPage />} />
|
||||
<Route path="/users/:id" element={<UserPage />} />
|
||||
<Route path="*" element={<Navigate to="/" replace />} />
|
||||
</Routes>
|
||||
</div>
|
||||
<PlayerBar />
|
||||
</div>
|
||||
<LockOverlay />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Gate() {
|
||||
const { auth } = useAuth();
|
||||
if (auth.status === 'loading')
|
||||
return (
|
||||
<div className="boot">
|
||||
<img src="/icon-192.png" alt="" />
|
||||
<Spinner label="겜녹이 여는 중" />
|
||||
</div>
|
||||
);
|
||||
if (auth.status === 'anon') {
|
||||
// 서버가 OAuth 결과를 ?login=... 으로 알려 준다
|
||||
const q = new URLSearchParams(window.location.search).get('login');
|
||||
return <LoginPage notMember={q === 'not_member'} error={q === 'error' || q === 'invalid' ? '로그인 중 문제가 생겼습니다. 다시 시도해 주세요.' : undefined} />;
|
||||
}
|
||||
if (auth.status === 'not_member') return <LoginPage notMember />;
|
||||
return (
|
||||
<StatusProvider>
|
||||
<DataProvider>
|
||||
<Shell />
|
||||
</DataProvider>
|
||||
</StatusProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export function App() {
|
||||
const reduce = useReducedMotion();
|
||||
useEffect(() => {
|
||||
document.documentElement.classList.toggle('reduce-motion', reduce);
|
||||
}, [reduce]);
|
||||
return (
|
||||
<MotionConfig reducedMotion={reduce ? 'always' : 'never'}>
|
||||
<AuthProvider>
|
||||
<Gate />
|
||||
</AuthProvider>
|
||||
</MotionConfig>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user