From 11db2e5104ba55dbb8b54b7187c5f991ed94bddc Mon Sep 17 00:00:00 2001 From: EJClaw Date: Sat, 31 Oct 2026 03:43:24 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B2=BD=EA=B8=B0=20=ED=83=AD:=20=EB=82=B4?= =?UTF-8?q?=EA=B0=80=20=ED=94=8C=EB=A0=88=EC=9D=B4=ED=95=9C=20=EA=B2=BD?= =?UTF-8?q?=EA=B8=B0=20=EC=A0=84=EB=B6=80=20(Riot=20=EA=B2=BD=EA=B8=B0=20?= =?UTF-8?q?=EA=B8=B0=EB=A1=9D=20=ED=8F=AC=ED=95=A8)=20=C2=B7=20=ED=95=84?= =?UTF-8?q?=ED=84=B0=20(=EC=A0=84=EC=B2=B4=20=EA=B2=BD=EA=B8=B0=20/=20?= =?UTF-8?q?=ED=83=80=EC=9E=84=EB=9D=BC=EC=9D=B8=20=EC=9E=88=EB=8A=94=20?= =?UTF-8?q?=EA=B2=BD=EA=B8=B0=20/=20=EB=AA=A9=EC=86=8C=EB=A6=AC=20?= =?UTF-8?q?=EB=85=B9=EC=9D=8C=EB=90=9C=20=EA=B2=BD=EA=B8=B0)=20=C2=B7=20?= =?UTF-8?q?=EC=A7=80=EB=82=9C=20=EA=B2=BD=EA=B8=B0=20=EB=8D=94=20=EB=B3=B4?= =?UTF-8?q?=EA=B8=B0=20=C2=B7=20=EC=B9=B4=EB=93=9C=EC=97=90=20=EB=85=B9?= =?UTF-8?q?=EC=9D=8C=20/=20=EA=B2=BD=EA=B8=B0=20=EA=B8=B0=EB=A1=9D?= =?UTF-8?q?=EB=A7=8C=20=ED=91=9C=EC=8B=9C=20=C2=B7=20=ED=83=80=EC=9E=84?= =?UTF-8?q?=EB=9D=BC=EC=9D=B8=20=EC=82=AC=EC=9D=B4=EB=93=9C=EB=B0=94?= =?UTF-8?q?=EB=8A=94=20=ED=83=80=EC=9E=84=EB=9D=BC=EC=9D=B8=20=EC=9E=88?= =?UTF-8?q?=EB=8A=94=20=EA=B2=BD=EA=B8=B0=EB=A7=8C=20=C2=B7=20=EB=AA=A9=20?= =?UTF-8?q?=EC=84=9C=EB=B2=84=EC=97=90=20=EA=B8=B0=EB=A1=9D=20=EA=B2=BD?= =?UTF-8?q?=EA=B8=B0=2070=EA=B0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- site/web/mock/data.mjs | 28 ++++++++++++ site/web/mock/server.mjs | 9 +++- site/web/src/lib/api.ts | 6 ++- site/web/src/pages/Sidebar.tsx | 17 +++++++- site/web/src/pages/TimelinePage.tsx | 2 +- site/web/src/pages/UserPages.tsx | 66 ++++++++++++++++++++++++++--- site/web/src/styles.css | 27 ++++++++++++ 7 files changed, 144 insertions(+), 11 deletions(-) diff --git a/site/web/mock/data.mjs b/site/web/mock/data.mjs index 1697a70..dd37855 100644 --- a/site/web/mock/data.mjs +++ b/site/web/mock/data.mjs @@ -580,6 +580,34 @@ function genReplayDemo(file) { } if (process.env.GVR_MOCK_REPLAY) genReplayDemo(process.env.GVR_MOCK_REPLAY); +// Riot 경기 기록에서 가져온 경기 (v1.9.0, 겜녹이가 꺼져 있을 때 한 경기): 녹음 · 타임라인 없음 +{ + const base = matches.find((m) => m.game === 'valorant'); + const MAPS = ['어센트', '바인드', '헤이븐', '로터스', '선셋']; + for (let i = 0; i < 70; i++) { + const start = NOW - (1 + i * 0.37) * 24 * 60 * MIN; + const ally = 13; + const enemy = (i * 5) % 12; + const win = i % 3 !== 0; + matches.push({ + ...base, + id: `val-hist-${i}`, + startedAt: start, + endedAt: start + 38 * MIN, + map: { ...base.map, name: MAPS[i % MAPS.length] }, + mode: i % 4 === 0 ? '일반전' : '경쟁전', + win, + score: win ? { ally, enemy } : { ally: enemy, enemy: ally }, + status: 'complete', + participants: [], + source: 'history', + utterances: [], + events: [], + replayPath: undefined, + }); + } +} + // ── 내보내기 ───────────────────────────────────────── export const db = { users: USERS, diff --git a/site/web/mock/server.mjs b/site/web/mock/server.mjs index a810926..e0633a3 100644 --- a/site/web/mock/server.mjs +++ b/site/web/mock/server.mjs @@ -115,7 +115,10 @@ function timeline(q) { return { items: page, next: items.length > limit ? enc(page[page.length - 1]) : null }; } -const summary = (m) => ({ id: m.id, game: m.game, startedAt: m.startedAt, endedAt: m.endedAt, map: m.map, mode: m.mode, win: m.win, score: m.score, status: m.status, participants: m.participants }); +const summary = (m) => ({ + id: m.id, game: m.game, startedAt: m.startedAt, endedAt: m.endedAt, map: m.map, mode: m.mode, win: m.win, score: m.score, status: m.status, participants: m.participants, + source: m.source ?? 'live', voice: m.utterances.length > 0, +}); function userProfile(id) { const user = db.users.find((u) => u.id === id); @@ -335,7 +338,9 @@ async function handle(req, res) { const game = q.get('game'); const before = q.get('before') ? Number(q.get('before')) : Infinity; const limit = Number(q.get('limit') ?? 20); - const list = db.matches.filter((x) => (!game || x.game === game) && x.startedAt < before).sort((a, b) => b.startedAt - a.startedAt).slice(0, limit).map(summary); + const has = q.get('has'); + const keep = (x) => (has === 'voice' ? x.utterances.length > 0 : has === 'timeline' ? x.source !== 'history' || x.utterances.length > 0 : true); + const list = db.matches.filter((x) => (!game || x.game === game) && x.startedAt < before && keep(x)).sort((a, b) => b.startedAt - a.startedAt).slice(0, limit).map(summary); return json(res, 200, list); } if ((m = p.match(/^\/api\/matches\/([^/]+)$/))) { diff --git a/site/web/src/lib/api.ts b/site/web/src/lib/api.ts index 20be89b..53fce64 100644 --- a/site/web/src/lib/api.ts +++ b/site/web/src/lib/api.ts @@ -42,6 +42,9 @@ export class ApiError extends Error { } } +/** 경기 탭 필터 */ +export type MatchHas = 'timeline' | 'voice'; + async function request(path: string, init: RequestInit = {}): Promise { let res: Response; try { @@ -162,7 +165,8 @@ export const api = { hideNoise: 1, })}`, ), - matches: (o: { game?: GameType; limit?: number; before?: number } = {}) => request(`/api/matches${qs(o)}`), + // has: timeline = 타임라인에 나오는 경기, voice = 목소리가 녹음된 경기 (v1.9.0 앱부터, 예전 앱은 무시하고 다 보냄) + matches: (o: { game?: GameType; limit?: number; before?: number; has?: MatchHas } = {}) => request(`/api/matches${qs(o)}`), match: (id: string) => request(`/api/matches/${encodeURIComponent(id)}`), /** 발로란트 리플레이(.vrf)에서 뽑은 재생 데이터. 없으면 404 replay_not_found, 게임 PC 가 변환 중이면 202 { status: 'converting' } */ // fresh: 새로고침 때는 브라우저 캐시를 거치지 않는다 (방금 내려받은 리플레이가 보이게) diff --git a/site/web/src/pages/Sidebar.tsx b/site/web/src/pages/Sidebar.tsx index 8ff89fa..da0e200 100644 --- a/site/web/src/pages/Sidebar.tsx +++ b/site/web/src/pages/Sidebar.tsx @@ -15,7 +15,9 @@ export function toggleUser(f: Filters, users: User[], id: string): string[] { return all.every((x) => nextSet.includes(x)) ? [] : nextSet; } -export function MatchItem({ m, on, onClick }: { m: MatchSummary; on?: boolean; onClick?: () => void }) { +/** tags: 경기 탭에서 녹음 · 기록만 표시 */ +export function MatchItem({ m, on, onClick, tags }: { m: MatchSummary; on?: boolean; onClick?: () => void; tags?: boolean }) { + const voice = m.voice ?? m.participants.length > 0; const dur = m.endedAt ? Math.round((m.endedAt - m.startedAt) / 60000) : null; const res = m.win == null ? '' : m.win ? '승' : '패'; const Tag = onClick ? 'button' : 'div'; @@ -32,6 +34,19 @@ export function MatchItem({ m, on, onClick }: { m: MatchSummary; on?: boolean; o {dur != null ? ` · ${dur}분` : ''} {m.status === 'live' && · 진행 중} + {tags && (voice || m.source === 'history') && ( +
+ {voice ? ( + + 🎙 녹음 + + ) : ( + + 경기 기록만 + + )} +
+ )} {res && {res}} diff --git a/site/web/src/pages/TimelinePage.tsx b/site/web/src/pages/TimelinePage.tsx index 1c3df4e..83e95f8 100644 --- a/site/web/src/pages/TimelinePage.tsx +++ b/site/web/src/pages/TimelinePage.tsx @@ -257,7 +257,7 @@ export function TimelinePage() { // 사이드바 경기 목록 · 선택한 경기 상세 useEffect(() => { api - .matches({ limit: 15, game: f.game === 'valorant' || f.game === 'lol' ? f.game : undefined }) + .matches({ limit: 15, game: f.game === 'valorant' || f.game === 'lol' ? f.game : undefined, has: 'timeline' }) .then(setMatches) .catch(() => {}); }, [f.game, epoch]); diff --git a/site/web/src/pages/UserPages.tsx b/site/web/src/pages/UserPages.tsx index af321d9..2933c5f 100644 --- a/site/web/src/pages/UserPages.tsx +++ b/site/web/src/pages/UserPages.tsx @@ -1,7 +1,7 @@ import { useEffect, useMemo, useState } from 'react'; import { Link, useNavigate, useParams } from 'react-router'; import type { GameType, MatchSummary, User, UserProfile } from '@gvr/shared'; -import { api } from '../lib/api'; +import { api, type MatchHas } from '../lib/api'; import { useStatus } from '../store/app'; import { fmtDuration, fmtDay } from '../lib/format'; import { sfx } from '../lib/sfx'; @@ -50,18 +50,53 @@ export function UsersPage() { ); } +const PAGE = 50; +/** 목소리가 녹음된 경기 (예전 앱은 voice 가 없어 말한 사람으로 본다) */ +const hasVoice = (m: MatchSummary) => m.voice ?? m.participants.length > 0; +const HAS_CHIPS: { has: MatchHas | null; label: string; title: string }[] = [ + { has: null, label: '전체 경기', title: '내가 플레이한 경기 전부 (앱이 꺼져 있을 때 한 경기는 Riot 경기 기록에서 가져옴)' }, + { has: 'timeline', label: '타임라인 있는 경기', title: '겜녹이가 켜져 있을 때 한 경기 (타임라인에서 대화 · 킬을 같이 볼 수 있음)' }, + { has: 'voice', label: '목소리 녹음된 경기', title: '디스코드 대화가 녹음된 경기' }, +]; + export function MatchesPage() { const [game, setGame] = useState(null); + const [has, setHas] = useState(null); const nav = useNavigate(); - const { data, err, retry } = useLoad(() => api.matches({ limit: 50, game: game ?? undefined }), [game]); + const { data, err, retry } = useLoad(() => api.matches({ limit: PAGE, game: game ?? undefined, has: has ?? undefined }), [game, has]); + // 더 보기: 지난 쪽 경기들 (필터가 바뀌면 처음부터) + const [more, setMore] = useState<{ list: MatchSummary[]; done: boolean; busy: boolean; err: unknown }>({ list: [], done: false, busy: false, err: null }); + useEffect(() => setMore({ list: [], done: false, busy: false, err: null }), [data]); + const all = useMemo(() => { + const seen = new Set(); + const out: MatchSummary[] = []; + for (const m of [...(data ?? []), ...more.list]) { + if (seen.has(m.id)) continue; + seen.add(m.id); + // 예전 앱은 has 를 모르고 다 보낸다: 목소리 필터는 여기서도 거른다 + if (has === 'voice' && !hasVoice(m)) continue; + out.push(m); + } + return out; + }, [data, more.list, has]); + const canMore = !!data && data.length >= PAGE && !more.done; + const loadMore = () => { + const last = more.list[more.list.length - 1] ?? data?.[data.length - 1]; + if (!last || more.busy) return; + setMore((s) => ({ ...s, busy: true, err: null })); + api + .matches({ limit: PAGE, game: game ?? undefined, has: has ?? undefined, before: last.startedAt }) + .then((r) => setMore((s) => ({ list: [...s.list, ...r], done: r.length < PAGE, busy: false, err: null }))) + .catch((e) => setMore((s) => ({ ...s, busy: false, err: e }))); + }; const groups = useMemo(() => { const g = new Map(); - for (const m of data ?? []) { + for (const m of all) { const d = fmtDay(m.startedAt); g.set(d, [...(g.get(d) ?? []), m]); } return [...g]; - }, [data]); + }, [all]); return (
@@ -78,19 +113,38 @@ export function MatchesPage() {
+
+ {HAS_CHIPS.map((c) => ( + + ))} +
{err != null && } {!data && !err && } - {data && data.length === 0 &&
경기 기록이 없습니다.
} + {data && all.length === 0 && ( +
+ {has === 'voice' ? '목소리가 녹음된 경기가 없습니다.' : has === 'timeline' ? '타임라인이 있는 경기가 없습니다.' : '경기 기록이 없습니다.'} +
+ )} {groups.map(([day, ms]) => (

{day}

{ms.map((m) => ( - nav(`/matches/${encodeURIComponent(m.id)}`)} /> + nav(`/matches/${encodeURIComponent(m.id)}`)} /> ))}
))} + {more.err != null && } + {canMore && ( +
+ +
+ )}
); } diff --git a/site/web/src/styles.css b/site/web/src/styles.css index cc15c35..3af28a9 100644 --- a/site/web/src/styles.css +++ b/site/web/src/styles.css @@ -2737,6 +2737,33 @@ button.match:hover { letter-spacing: 1px; margin: 20px 0 8px; } +.match-has { + margin: 4px 0 2px; +} +.m-tags { + display: flex; + gap: 4px; + margin-top: 3px; +} +.m-tag { + font-size: 11px; + padding: 0 6px; + border-radius: 4px; + line-height: 17px; +} +.m-tag.voice { + background: #0f2e2c; + color: #7fe9e1; +} +.m-tag.hist { + background: #1a2633; + color: var(--muted); +} +.more-row { + display: flex; + justify-content: center; + margin: 18px 0 8px; +} .match-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));