Riot ID 자동 갱신 (Riot 클라이언트에 붙으면 바로 · 10분마다 이름 서비스로 연결 계정의 지금 Riot ID 확인, puuid 는 그대로 두고 표시 이름만) · 경기 탭 데스매치 숨김 · 모드(GET /api/matches/modes) · 날짜(after) 필터 (예전 앱은 사이트가 거름) · 범인찾기 목록 데스매치 숨김 · 녹음 없거나 끊긴 경기도 범인찾기 (eligibility.notes, AI 자료에 안내 줄) · Riot 경기 기록 마지막 확인 시각(historyAt) 안내 · 테스트

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
EJClaw
2026-11-21 07:14:07 +09:00
parent 8782df2111
commit 5e756f9eb8
21 changed files with 413 additions and 40 deletions

View File

@@ -1,6 +1,7 @@
import { useEffect, useRef, useState } from 'react';
import { GAME_NAME, historyStatus, resumeText, type GameType } from '@gvr/shared';
import { api } from '../lib/api';
import { fmtWhen } from '../lib/format';
import { useData } from '../store/app';
/**
@@ -69,3 +70,31 @@ export function HistoryImport({ onDone }: { onDone: () => void }) {
</div>
);
}
/**
* Riot 경기 기록을 언제 확인했는지 (v1.11.0 앱부터, 경기 탭). 앱이 꺼져 있던 때 한 경기는 이 PC 에서 Riot 클라이언트에
* 로그인해 있어야 가져올 수 있어서, 아직 못 가져왔으면 그 방법을 알려 준다. 가져오는 중이면 위 진행 바가 대신 보인다.
*/
export function HistoryHint() {
const { overview } = useData();
const rows = (overview?.live ?? []).filter((g) => g.enabled && !g.history && g.historyAt !== undefined);
if (!rows.length) return null;
return (
<div className="hist-hint dim small">
{rows.map((g) => {
const client = g.game === 'valorant' ? 'Riot 클라이언트' : '롤 클라이언트';
const text =
g.historyAt != null
? `Riot 경기 기록 ${fmtWhen(g.historyAt)} 확인${g.connected ? ' · 30분마다 새 경기를 가져옵니다' : ` · ${client}를 켜면 그사이 한 경기를 가져옵니다`}`
: g.connected
? '앱이 꺼져 있던 때 한 경기를 곧 가져옵니다'
: `앱이 꺼져 있던 때 한 경기는 아직 못 가져왔습니다. 이 PC 에서 ${client}에 로그인해 두면 자동으로 가져옵니다`;
return (
<div key={g.game}>
<b>{GAME_NAME[g.game]}</b> {text}
</div>
);
})}
</div>
);
}

View File

@@ -166,7 +166,11 @@ export const api = {
})}`,
),
// has: timeline = 타임라인에 나오는 경기, voice = 목소리가 녹음된 경기 (v1.9.0 앱부터, 예전 앱은 무시하고 다 보냄)
matches: (o: { game?: GameType; limit?: number; before?: number; has?: MatchHas } = {}) => request<MatchSummary[]>(`/api/matches${qs(o)}`),
// mode · after (v1.11.0 앱부터): 모드 이름("경쟁전") · 이 시각 이후 시작한 경기. 데스매치는 앱이 늘 뺀다 (예전 앱은 사이트가 거름)
matches: (o: { game?: GameType; limit?: number; before?: number; after?: number; has?: MatchHas; mode?: string } = {}) =>
request<MatchSummary[]>(`/api/matches${qs(o)}`),
/** 경기 탭 모드 필터 목록 (v1.11.0 앱부터, 예전 앱은 404) */
matchModes: (game?: GameType) => request<{ game: GameType; mode: string; count: number }[]>(`/api/matches/modes${qs({ game })}`),
match: (id: string) => request<MatchDetail>(`/api/matches/${encodeURIComponent(id)}`),
/** 발로란트 리플레이(.vrf)에서 뽑은 재생 데이터. 없으면 404 replay_not_found, 게임 PC 가 변환 중이면 202 { status: 'converting' } */
// fresh: 새로고침 때는 브라우저 캐시를 거치지 않는다 (방금 내려받은 리플레이가 보이게)

View File

@@ -188,7 +188,7 @@ function MatchRow({ x, on, running, onClick }: { x: CulpritMatchItem; on: boolea
<small>
{m.mode} · {fmtWhen(m.startedAt)}
{m.endedAt ? ` · ${fmtDuration(m.endedAt - m.startedAt)}` : ''}
{x.eligibility.reasons[0] ? ` · ${x.eligibility.reasons[0]}` : ''}
{x.eligibility.reasons[0] ? ` · ${x.eligibility.reasons[0]}` : x.eligibility.notes?.[0] ? ` · ${x.eligibility.notes[0].split(':')[0]}` : ''}
</small>
</span>
<span className={`cu-score ${m.win === null ? '' : m.win ? 'win' : 'loss'}`}>{score}</span>
@@ -236,7 +236,8 @@ function PrepPanel({ info, budget, progress, onStart, onOpen }: { info: CulpritM
[true, m.game === 'valorant' ? '킬 · 스파이크 · 라운드 결과 이벤트' : '킬 · 오브젝트 이벤트', `${s.events}개`],
[e.state !== 'pending' || !e.reasons[0]?.startsWith('음성 변환'), '음성 대화 (텍스트 변환 완료)', `${s.utterances}문장`],
[true, '인게임 채팅 (팀 · 전체)', `${s.chats}개`],
[!e.reasons.some((r) => r.startsWith('녹음')), '녹음이 경기 시작부터 끝까지 이어짐', ''],
// 녹음이 없거나 끊겨도 분석은 된다 (v1.11.0 앱): 빠진 것만 ✕ 로 보이고 아래 안내를 단다
[!e.reasons.some((r) => r.startsWith('녹음')) && !e.notes?.length, '녹음이 경기 시작부터 끝까지 이어짐', e.notes?.length ? '없어도 분석 가능' : ''],
];
return (
<>
@@ -261,7 +262,7 @@ function PrepPanel({ info, budget, progress, onStart, onOpen }: { info: CulpritM
<section className="panel">
<h4>
<span>분석에 쓰는 기록</span>
<span className={`cu-st ${e.state}`}>{e.state === 'ready' || e.state === 'done' ? '모두 있음' : STATE_LABEL[e.state]}</span>
<span className={`cu-st ${e.state}`}>{e.state === 'ready' || e.state === 'done' ? (e.notes?.length ? '분석 가능' : '모두 있음') : STATE_LABEL[e.state]}</span>
</h4>
{checks.map(([ok, label, val]) => (
<div key={label} className={`cu-check${ok ? '' : ' no'}`}>
@@ -272,6 +273,7 @@ function PrepPanel({ info, budget, progress, onStart, onOpen }: { info: CulpritM
))}
{!s.extraStats && <div className="dim small cu-note">이 경기는 피해량 · 시야 같은 추가 지표가 없어 기본 기록으로 분석합니다.</div>}
{e.reasons.length > 0 && <div className="cu-reason">{e.reasons.join(' · ')}</div>}
{!!e.notes?.length && <div className="dim small cu-note">{e.notes.join(' · ')}</div>}
<div className="dim small cu-note">음성 파일은 7일 뒤 지워져도 괜찮습니다. 분석은 텍스트로 합니다.</div>
</section>
<section className="panel">

View File

@@ -3,11 +3,11 @@ import { Link, useNavigate, useParams } from 'react-router';
import type { GameType, MatchSummary, User, UserProfile } from '@gvr/shared';
import { api, type MatchHas } from '../lib/api';
import { useStatus } from '../store/app';
import { fmtDuration, fmtDay } from '../lib/format';
import { dateInputToMs, dateInputValue, fmtDuration, fmtDay } from '../lib/format';
import { sfx } from '../lib/sfx';
import { Avatar, ErrorBox, Spinner } from '../components/common';
import { MatchItem } from './Sidebar';
import { HistoryImport } from '../components/HistoryImport';
import { HistoryHint, HistoryImport } from '../components/HistoryImport';
function useLoad<T>(fn: () => Promise<T>, deps: unknown[]) {
const { epoch } = useStatus();
@@ -60,11 +60,41 @@ const HAS_CHIPS: { has: MatchHas | null; label: string; title: string }[] = [
{ has: 'voice', label: '목소리 녹음된 경기', title: '디스코드 대화가 녹음된 경기' },
];
/** 경기 목록에 보이지 않는 모드 (예전 앱은 다 보내서 여기서도 거른다) */
const HIDDEN_MODE = '데스매치';
export function MatchesPage() {
const [game, setGame] = useState<GameType | null>(null);
const [game, setGameRaw] = useState<GameType | null>(null);
const [has, setHas] = useState<MatchHas | null>(null);
const [mode, setMode] = useState<string | null>(null);
// 날짜 (한국 시각): from = 시작 날 0시, to = 끝 날 23:59:59.999
const [from, setFrom] = useState<number | undefined>(undefined);
const [to, setTo] = useState<number | undefined>(undefined);
// 게임을 바꾸면 그 게임에 없을 수 있는 모드는 풀어 준다
const setGame = (g: GameType | null) => {
setGameRaw(g);
setMode(null);
};
const nav = useNavigate();
const { data, err, retry } = useLoad<MatchSummary[]>(() => api.matches({ limit: PAGE, game: game ?? undefined, has: has ?? undefined }), [game, has]);
const query = { limit: PAGE, game: game ?? undefined, has: has ?? undefined, mode: mode ?? undefined, after: from, before: to === undefined ? undefined : to + 1 };
const { data, err, retry } = useLoad<MatchSummary[]>(() => api.matches(query), [game, has, mode, from, to]);
// 모드 목록: 예전 앱(404)은 불러온 경기에서 만든다
const [modeList, setModeList] = useState<{ mode: string; count: number | null }[] | null>(null);
useEffect(() => {
let alive = true;
api
.matchModes(game ?? undefined)
.then((r) => {
if (!alive) return;
const by = new Map<string, number>();
for (const x of r) by.set(x.mode, (by.get(x.mode) ?? 0) + x.count);
setModeList([...by].map(([m, count]) => ({ mode: m, count })));
})
.catch(() => alive && setModeList(null));
return () => {
alive = false;
};
}, [game, data]);
// 더 보기: 지난 쪽 경기들 (필터가 바뀌면 처음부터)
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]);
@@ -74,22 +104,30 @@ export function MatchesPage() {
for (const m of [...(data ?? []), ...more.list]) {
if (seen.has(m.id)) continue;
seen.add(m.id);
// 예전 앱은 has 를 모르고 다 보낸다: 목소리 필터는 여기서도 거른다
// 예전 앱은 has · 모드 · 날짜를 모르고 다 보낸다: 여기서도 거른다
if (has === 'voice' && !hasVoice(m)) continue;
if (m.mode === HIDDEN_MODE || (mode && m.mode !== mode)) continue;
if ((from !== undefined && m.startedAt < from) || (to !== undefined && m.startedAt > to)) continue;
out.push(m);
}
return out;
}, [data, more.list, has]);
}, [data, more.list, has, mode, from, to]);
const modes = useMemo(() => {
if (modeList) return modeList;
const seen = [...new Set([...(data ?? []), ...more.list].filter((m) => !game || m.game === game).map((m) => m.mode))];
return seen.filter((m) => m !== HIDDEN_MODE).map((m) => ({ mode: m, count: null }));
}, [modeList, data, more.list, game]);
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 })
.matches({ ...query, 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 filtered = !!mode || from !== undefined || to !== undefined;
const groups = useMemo(() => {
const g = new Map<string, MatchSummary[]>();
for (const m of all) {
@@ -121,12 +159,48 @@ export function MatchesPage() {
</button>
))}
</div>
<div className="match-filters">
<select className="mf-sel" value={mode ?? ''} onChange={(e) => setMode(e.target.value || null)} aria-label="모드">
<option value="">모든 모드</option>
{mode && !modes.some((m) => m.mode === mode) && <option value={mode}>{mode}</option>}
{modes.map((m) => (
<option key={m.mode} value={m.mode}>
{m.mode}
{m.count !== null ? ` (${m.count})` : ''}
</option>
))}
</select>
<div className="dates mf-dates">
<input type="date" value={dateInputValue(from)} max={dateInputValue(to)} onChange={(e) => setFrom(dateInputToMs(e.target.value))} aria-label="시작 날짜" />
<span className="dim">~</span>
<input type="date" value={dateInputValue(to)} min={dateInputValue(from)} onChange={(e) => setTo(dateInputToMs(e.target.value, true))} aria-label="끝 날짜" />
</div>
{filtered && (
<button
className="link-btn"
onClick={() => {
setMode(null);
setFrom(undefined);
setTo(undefined);
}}
>
모드 · 날짜 초기화
</button>
)}
</div>
<HistoryImport onDone={retry} />
<HistoryHint />
{err != null && <ErrorBox error={err} onRetry={retry} />}
{!data && !err && <Spinner label="경기 목록 불러오는 중" />}
{data && all.length === 0 && (
<div className="empty">
{has === 'voice' ? '목소리가 녹음된 경기가 없습니다.' : has === 'timeline' ? '타임라인이 있는 경기가 없습니다.' : '경기 기록이 없습니다.'}
{filtered
? '고른 모드 · 날짜에 맞는 경기가 없습니다.'
: has === 'voice'
? '목소리가 녹음된 경기가 없습니다.'
: has === 'timeline'
? '타임라인이 있는 경기가 없습니다.'
: '경기 기록이 없습니다.'}
</div>
)}
{groups.map(([day, ms]) => (

View File

@@ -2740,6 +2740,29 @@ button.match:hover {
.match-has {
margin: 4px 0 2px;
}
.match-filters {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10px;
margin: 8px 0 2px;
}
.mf-sel {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 7px;
padding: 6px 8px;
font-size: 12.5px;
color: #c6d1dc;
}
.mf-dates input {
flex: none;
width: 140px;
}
.hist-hint {
margin: 8px 0 2px;
line-height: 1.6;
}
.m-tags {
display: flex;
gap: 4px;