WIP v1.3.7: 기록 묶음(경기 · 경기 전후 대화) 관리 · zip 내보내기/받아오기
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,8 @@ import type {
|
||||
UtteranceItem,
|
||||
UtteranceInfo,
|
||||
GameType,
|
||||
BundleInfo,
|
||||
BundleImportResult,
|
||||
} from '@gvr/shared';
|
||||
|
||||
import { reportClient } from './report';
|
||||
@@ -159,6 +161,23 @@ export const api = {
|
||||
if (res.status === 503 && b.error === 'device_offline') emit('device_offline');
|
||||
return { ok: false, status: res.status, error: b.error ?? 'error', message: b.message ?? '분석을 시작하지 못했습니다' };
|
||||
},
|
||||
/** 기록 묶음 (v1.3.7~ 앱) */
|
||||
bundles: () => request<{ bundles: BundleInfo[] }>('/api/bundles').then((r) => r.bundles),
|
||||
deleteBundles: (ids: string[]) => request<{ bundles: number; utterances: number; files: number }>('/api/bundles/delete', { method: 'POST', body: JSON.stringify({ ids }) }),
|
||||
bundleExportUrl: (ids: string[]) => `/api/bundles/export?ids=${ids.map(encodeURIComponent).join(',')}`,
|
||||
/** zip 받아오기. 실패하면 서버가 준 이유("받아오기 실패: …")를 담은 Error */
|
||||
importBundle: async (file: Blob): Promise<BundleImportResult> => {
|
||||
let res: Response;
|
||||
try {
|
||||
res = await fetch('/api/bundles/import', { method: 'POST', credentials: 'include', headers: { 'content-type': 'application/zip', accept: 'application/json' }, body: file });
|
||||
} catch {
|
||||
throw new Error('받아오기 실패: 네트워크 오류');
|
||||
}
|
||||
const b = await res.json().catch(() => ({}));
|
||||
if (res.ok) return b as BundleImportResult;
|
||||
if (res.status === 503) emit('device_offline');
|
||||
throw new Error(b.message ?? (res.status === 413 ? '받아오기 실패: zip 이 너무 큽니다 (300MB 까지)' : `받아오기 실패 (${res.status} ${b.error ?? ''})`));
|
||||
},
|
||||
utteranceInfo: (id: string) => request<UtteranceInfo>(`/api/utterances/${encodeURIComponent(id)}/info`),
|
||||
correct: (id: string, text: string) =>
|
||||
request<UtteranceItem>(`/api/utterances/${encodeURIComponent(id)}`, { method: 'PATCH', body: JSON.stringify({ text }) }),
|
||||
|
||||
@@ -15,6 +15,11 @@ export function fmtWhen(ts: number): string {
|
||||
return `${md} ${hm}`;
|
||||
}
|
||||
|
||||
/** 날짜만: "오늘" · "어제" · "10월 7일" (fmtWhen 에서 시각을 뺀 것) */
|
||||
export function fmtDay(ts: number): string {
|
||||
return fmtWhen(ts).replace(/\s\d{2}:\d{2}$/, '');
|
||||
}
|
||||
|
||||
export function fmtHM(ts: number): string {
|
||||
return new Intl.DateTimeFormat('ko-KR', { timeZone: TZ, hour: '2-digit', minute: '2-digit', hour12: false }).format(ts);
|
||||
}
|
||||
@@ -54,7 +59,7 @@ export function fmtSec(sec: number): string {
|
||||
}
|
||||
|
||||
export function realTip(ts: number) {
|
||||
return `현실 시간 ${fmtWhen(ts).split(' ')[0]} ${fmtReal(ts)}`;
|
||||
return `현실 시간 ${fmtDay(ts)} ${fmtReal(ts)}`;
|
||||
}
|
||||
|
||||
/** "YYYY-MM-DD" (KST) ↔ ms */
|
||||
|
||||
Reference in New Issue
Block a user