M1 웹 + 배포: 홈·코드 입장·대기실·오목 화면·결과·계정, E2E, Docker/Caddy
- 웹(React+Vite): 홈(큰 버튼 2개·하던 게임 돌아가기), 6자리 코드 입력(붙여넣기 감지·자동 입장), 링크 입장(닉네임 한 칸), 대기실(코드/링크 복사·공유·QR·자리·준비·방장 메뉴·설정), 오목(SVG 판·두 번 눌러 확정·금수/위험 표시·시계·무르기·무승부·기권·키보드 조작·스크린리더 안내), 결과(한 판 더 투표·방 전적·공정성 확인), 채팅·반응, 계정(닉네임 변경·글자 크기·테마·소리·진동) - WS 클라이언트: 지수 백오프+지터 재연결, 화면 복귀/온라인 즉시 재연결, seq 순서 처리, ping/pong 지연·시계 보정, 서버 재시작 안내, 다른 창 접속 처리 - @bg/shared/lite: 브라우저용 진입점(zod 제외) → 첫 화면 JS 약 90KB gzip - e2e/omok.e2e.ts: 브라우저 두 개(모바일·PC)로 방 만들기→링크 입장→대국→새로고침 복구→승리→한 판 더 - deploy: Dockerfile(운영 의존성만, 267MB), docker-compose(app+Caddy), Caddyfile(보안 헤더·CSP), .env.example - 프록시 뒤에서만 X-Forwarded-For 신뢰(TRUST_PROXY=1) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
64
apps/web/src/main.tsx
Normal file
64
apps/web/src/main.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
import { StrictMode, Suspense, lazy, useEffect } from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import { BrowserRouter, Route, Routes, useLocation, useNavigate } from 'react-router';
|
||||
import 'pretendard/dist/web/variable/pretendardvariable-dynamic-subset.css';
|
||||
import './styles/global.css';
|
||||
import { ConnectionBanner, Toasts } from './components/ui';
|
||||
import { useSession } from './store/session';
|
||||
import { toast } from './store/toast';
|
||||
import { Home } from './pages/Home';
|
||||
|
||||
const JoinPage = lazy(() => import('./pages/JoinPage'));
|
||||
const RoomPage = lazy(() => import('./pages/RoomPage'));
|
||||
const GamePage = lazy(() => import('./pages/GamePage'));
|
||||
const MePage = lazy(() => import('./pages/MePage'));
|
||||
const RulesPage = lazy(() => import('./pages/RulesPage'));
|
||||
const NotFound = lazy(() => import('./pages/NotFound'));
|
||||
|
||||
function Shell() {
|
||||
const loaded = useSession((s) => s.loaded);
|
||||
const nav = useNavigate();
|
||||
const loc = useLocation();
|
||||
useEffect(() => {
|
||||
void useSession.getState().refresh();
|
||||
const onUnauthorized = () => void useSession.getState().refresh();
|
||||
window.addEventListener('bg:unauthorized', onUnauthorized);
|
||||
return () => window.removeEventListener('bg:unauthorized', onUnauthorized);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
const q = new URLSearchParams(loc.search);
|
||||
if (q.get('linked') === '1') toast('디스코드 계정과 연결했어요.');
|
||||
if (q.get('login') === 'failed') toast('디스코드 로그인에 실패했어요. 다시 시도해 주세요.', 'error');
|
||||
if (q.has('linked') || q.has('login')) {
|
||||
q.delete('linked');
|
||||
q.delete('login');
|
||||
nav({ pathname: loc.pathname, search: q.toString() }, { replace: true });
|
||||
}
|
||||
}, [loc.search]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
if (!loaded) return <div className="page muted">불러오는 중…</div>;
|
||||
return (
|
||||
<>
|
||||
<ConnectionBanner />
|
||||
<Toasts />
|
||||
<Suspense fallback={<div className="page muted">불러오는 중…</div>}>
|
||||
<Routes>
|
||||
<Route path="/" element={<Home />} />
|
||||
<Route path="/j" element={<JoinPage />} />
|
||||
<Route path="/r/:code" element={<RoomPage />} />
|
||||
<Route path="/g/:gameId" element={<GamePage />} />
|
||||
<Route path="/rules/:gameId" element={<RulesPage />} />
|
||||
<Route path="/me" element={<MePage />} />
|
||||
<Route path="*" element={<NotFound />} />
|
||||
</Routes>
|
||||
</Suspense>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
createRoot(document.getElementById('root')!).render(
|
||||
<StrictMode>
|
||||
<BrowserRouter>
|
||||
<Shell />
|
||||
</BrowserRouter>
|
||||
</StrictMode>,
|
||||
);
|
||||
Reference in New Issue
Block a user