- 웹(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>
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { useEffect, useState } from 'react';
|
|
import { Sheet, CodeLabel } from './ui';
|
|
|
|
/** QR is generated lazily so the library is not in the first-page bundle. */
|
|
export function QrModal({ url, code, onClose }: { url: string; code: string; onClose: () => void }) {
|
|
const [cells, setCells] = useState<{ n: number; path: string } | null>(null);
|
|
useEffect(() => {
|
|
let alive = true;
|
|
import('qrcode-generator').then(({ default: qrcode }) => {
|
|
const qr = qrcode(0, 'M');
|
|
qr.addData(url);
|
|
qr.make();
|
|
const n = qr.getModuleCount();
|
|
let path = '';
|
|
for (let y = 0; y < n; y++) for (let x = 0; x < n; x++) if (qr.isDark(y, x)) path += `M${x} ${y}h1v1h-1z`;
|
|
if (alive) setCells({ n, path });
|
|
});
|
|
return () => {
|
|
alive = false;
|
|
};
|
|
}, [url]);
|
|
return (
|
|
<Sheet onClose={onClose} label="QR 코드">
|
|
<h2>휴대폰 카메라로 찍으면 들어와요</h2>
|
|
<div style={{ background: '#fff', borderRadius: 16, padding: 12, width: 'min(80vw, 320px)', aspectRatio: '1', alignSelf: 'center' }}>
|
|
{cells ? (
|
|
<svg viewBox={`-2 -2 ${cells.n + 4} ${cells.n + 4}`} width="100%" height="100%" role="img" aria-label="초대 QR 코드" shapeRendering="crispEdges">
|
|
<path d={cells.path} fill="#000" />
|
|
</svg>
|
|
) : (
|
|
<p className="muted">만드는 중…</p>
|
|
)}
|
|
</div>
|
|
<p style={{ textAlign: 'center', fontSize: '1.6rem', fontWeight: 700 }}>
|
|
코드 <CodeLabel code={code} />
|
|
</p>
|
|
<button className="btn btn-secondary btn-block" onClick={onClose}>
|
|
닫기
|
|
</button>
|
|
</Sheet>
|
|
);
|
|
}
|