diff --git a/site/web/mock/server.mjs b/site/web/mock/server.mjs index 897337b..a810926 100644 --- a/site/web/mock/server.mjs +++ b/site/web/mock/server.mjs @@ -347,7 +347,8 @@ async function handle(req, res) { if ((m = p.match(/^\/api\/matches\/([^/]+)\/replay$/))) { const mt = db.matches.find((x) => x.id === decodeURIComponent(m[1])); if (!mt) return json(res, 404, { error: 'not_found' }); - if (!mt.replayPath) return json(res, 404, { error: 'replay_not_found' }); + // 파일을 지웠다가 다시 두면 "리플레이 없음 → 내려받고 새로고침" 을 흉내 낼 수 있다 + if (!mt.replayPath || !fs.existsSync(mt.replayPath)) return json(res, 404, { error: 'replay_not_found' }); res.writeHead(200, { 'content-type': 'application/json' }); return fs.createReadStream(mt.replayPath).pipe(res); } diff --git a/site/web/src/components/ReplayPanel.tsx b/site/web/src/components/ReplayPanel.tsx index 19c4a2c..26eefbd 100644 --- a/site/web/src/components/ReplayPanel.tsx +++ b/site/web/src/components/ReplayPanel.tsx @@ -14,6 +14,8 @@ export function ReplayPanel({ m }: { m: MatchDetail }) { const [replay, setReplay] = useState(null); const [err, setErr] = useState(null); const [converting, setConverting] = useState(false); + // 새로고침을 누를 때마다 1씩 올려 리플레이를 다시 묻는다 + const [reload, setReload] = useState(0); useEffect(() => { if (!open || replay) return; let alive = true; @@ -22,7 +24,7 @@ export function ReplayPanel({ m }: { m: MatchDetail }) { // 처음 열면 게임 PC 가 리플레이를 변환한다 (보통 10초 안팎). 변환 중(202)이면 3초 뒤 다시 묻는다 (5분까지) const ask = (tries: number) => api - .replay(m.id) + .replay(m.id, reload > 0) .then((r) => { if (!alive) return; if ('status' in r && r.status === 'converting') { @@ -46,12 +48,17 @@ export function ReplayPanel({ m }: { m: MatchDetail }) { alive = false; if (timer) clearTimeout(timer); }; - }, [open, m.id, replay]); + }, [open, m.id, replay, reload]); const sync = useMemo(() => (replay ? computeSync(m, replay) : null), [m, replay]); // replay_not_found: 앱이 리플레이를 못 찾음. 다른 404: 이 앱 버전에는 리플레이 기능이 아직 없음 const missing = err instanceof ApiError && err.status === 404 && err.code === 'replay_not_found'; const appTooOld = err instanceof ApiError && err.status === 404 && err.code === 'Not Found'; // Fastify 기본 404 (경로 없음) const failed = err instanceof ApiError && err.status === 422 && err.code === 'replay_failed'; + const refresh = ( + + ); return ( ) : missing ? ( -
- 이 경기 리플레이가 아직 없습니다. 발로란트 경력 탭에서 이 경기의 리플레이를 내려받으면 게임 PC 앱이 찾아서 변환합니다 (몇 초 걸림). +
+
+ 리플레이 파일 없음 +
+ 게임 PC 에 이 경기의 리플레이 파일이 없습니다. 발로란트 경력 탭에서 이 경기의 리플레이를 내려받은 뒤 새로고침을 누르면 게임 PC 앱이 찾아서 + 변환합니다 (몇 초 걸림). +
+
+ {refresh}
) : appTooOld ? ( -
지금 게임 PC 앱 버전은 아직 리플레이를 보내지 않습니다. 리플레이 자동 변환이 들어간 앱으로 업데이트하면 볼 수 있습니다.
+
+
지금 게임 PC 앱 버전은 아직 리플레이를 보내지 않습니다. 리플레이 자동 변환이 들어간 앱으로 업데이트하면 볼 수 있습니다.
+ {refresh} +
) : failed ? ( -
게임 PC 가 이 경기 리플레이를 변환하지 못했습니다. 발로란트 패치로 리플레이 형식이 바뀌었을 수 있습니다. ({(err as ApiError).detail ?? '이유 모름'})
+
+
게임 PC 가 이 경기 리플레이를 변환하지 못했습니다. 발로란트 패치로 리플레이 형식이 바뀌었을 수 있습니다. ({(err as ApiError).detail ?? '이유 모름'})
+ {refresh} +
) : err ? ( -
리플레이를 불러오지 못했습니다: {err instanceof Error ? err.message : String(err)}
+
+
리플레이를 불러오지 못했습니다: {err instanceof Error ? err.message : String(err)}
+ {refresh} +
) : !replay || !sync ? ( ) : ( diff --git a/site/web/src/lib/api.ts b/site/web/src/lib/api.ts index c47d27d..20be89b 100644 --- a/site/web/src/lib/api.ts +++ b/site/web/src/lib/api.ts @@ -165,7 +165,9 @@ export const api = { matches: (o: { game?: GameType; limit?: number; before?: number } = {}) => request(`/api/matches${qs(o)}`), match: (id: string) => request(`/api/matches/${encodeURIComponent(id)}`), /** 발로란트 리플레이(.vrf)에서 뽑은 재생 데이터. 없으면 404 replay_not_found, 게임 PC 가 변환 중이면 202 { status: 'converting' } */ - replay: (id: string) => request(`/api/matches/${encodeURIComponent(id)}/replay`), + // fresh: 새로고침 때는 브라우저 캐시를 거치지 않는다 (방금 내려받은 리플레이가 보이게) + replay: (id: string, fresh = false) => + request(`/api/matches/${encodeURIComponent(id)}/replay`, fresh ? { cache: 'no-cache' } : {}), culpritMatches: (o: { game?: GameType; limit?: number } = {}) => request(`/api/culprit/matches${qs(o)}`), culpritMatch: (id: string) => request(`/api/culprit/matches/${encodeURIComponent(id)}`), culpritBudget: () => request('/api/culprit/budget'), diff --git a/site/web/src/styles.css b/site/web/src/styles.css index e822cfe..cc15c35 100644 --- a/site/web/src/styles.css +++ b/site/web/src/styles.css @@ -3936,6 +3936,21 @@ button.match:hover { } /* ── 3D 리플레이 (components/ReplayViewer.tsx) ── */ +.replay-msg { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; +} +.replay-msg b { + display: block; + margin-bottom: 2px; + color: #e6edf3; + font-size: 13px; +} +.replay-msg .mini-btn { + flex: none; +} .replay-panel { flex: none; }