M5: 포터블 exe 앱 (트레이·설정 창·첫 실행 마법사) + M6 사전 기능
- app/src/main: Electron 메인(트레이 상태 아이콘, 설정 창, 단일 실행, DPAPI safeStorage, 스모크 모드), IPC(window.gvr), 파인튜닝 관리 - app/src/renderer: 설정 8개 탭 + 5단계 첫 실행 마법사 (React) - electron-builder: GameVoiceRecorder.exe, zip(폴더 포터블) + 단일 exe 포터블, 워커·리소스 포함 - 사전: 사이트에서 단어·교정 규칙 추가/삭제(/api/dictionary), 게임 패치 이름 자동 추가, 묶음별 중복 허용 + DB 마이그레이션 - 사이트 서버: 종료 시 WebSocket 먼저 끊기(재시작 멈춤 수정) + 재연결 테스트 - scripts/finetune-e2e.mts, stt-eval.mts Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
115
site/web/src/pages/DictionaryPage.tsx
Normal file
115
site/web/src/pages/DictionaryPage.tsx
Normal file
@@ -0,0 +1,115 @@
|
||||
import { useEffect, useMemo, useState } from 'react';
|
||||
import { api, type DictionaryResponse } from '../lib/api';
|
||||
import { useStatus } from '../store/app';
|
||||
import { sfx } from '../lib/sfx';
|
||||
import { ErrorBox, Spinner } from '../components/common';
|
||||
|
||||
const SRC: Record<string, string> = { builtin: '기본', user: '설정', site: '사이트' };
|
||||
|
||||
/** 단어사전: 자주 쓰는 말·별명(핫워드)과 교정 규칙. 사이트에서 문장을 고치면 여기에 자동으로 쌓인다. */
|
||||
export function DictionaryPage() {
|
||||
const { epoch } = useStatus();
|
||||
const [data, setData] = useState<DictionaryResponse | null>(null);
|
||||
const [err, setErr] = useState<unknown>(null);
|
||||
const [n, setN] = useState(0);
|
||||
const [q, setQ] = useState('');
|
||||
const [word, setWord] = useState('');
|
||||
const [from, setFrom] = useState('');
|
||||
const [to, setTo] = useState('');
|
||||
const [busy, setBusy] = useState(false);
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
api
|
||||
.dictionary()
|
||||
.then((d) => alive && setData(d))
|
||||
.catch((e) => alive && setErr(e));
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [epoch, n]);
|
||||
const words = useMemo(() => (data?.entries ?? []).filter((e) => e.kind === 'hotword' && (!q || e.word.includes(q))), [data, q]);
|
||||
const rules = useMemo(() => (data?.entries ?? []).filter((e) => e.kind === 'correction' && (!q || e.word.includes(q) || (e.from ?? '').includes(q))), [data, q]);
|
||||
const run = async (fn: () => Promise<unknown>) => {
|
||||
setBusy(true);
|
||||
try {
|
||||
await fn();
|
||||
sfx('click');
|
||||
setN((x) => x + 1);
|
||||
} catch (e) {
|
||||
setErr(e);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
};
|
||||
if (err) return <main className="page-pad"><ErrorBox error={err} onRetry={() => { setErr(null); setN((x) => x + 1); }} /></main>;
|
||||
if (!data) return <main className="page-pad"><Spinner /></main>;
|
||||
return (
|
||||
<main className="page-pad dict-page">
|
||||
<h2 className="page-h h">단어사전</h2>
|
||||
<p className="muted small">
|
||||
여기 넣은 단어는 음성 인식할 때 힌트로 쓰이고, 교정 규칙은 인식 결과를 바로 고칩니다. 타임라인에서 문장을 고치면 바뀐 단어가 자동으로 추가됩니다.
|
||||
</p>
|
||||
<div className="dict-packs">
|
||||
{data.packs.map((p) => (
|
||||
<span key={p.key} className="chip">
|
||||
{p.label} <b>{p.count.toLocaleString()}</b>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
<input className="dict-search" placeholder="단어 검색" value={q} onChange={(e) => setQ(e.target.value)} />
|
||||
<div className="dict-grid">
|
||||
<section className="card">
|
||||
<h3 className="h">자주 쓰는 말 · 별명 <span className="dim small">{words.length}</span></h3>
|
||||
<form
|
||||
className="dict-form"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
if (word.trim()) void run(async () => { await api.addWord(word.trim()); setWord(''); });
|
||||
}}
|
||||
>
|
||||
<input placeholder="예: 승한이, 개꿀맵, 로테" value={word} onChange={(e) => setWord(e.target.value)} />
|
||||
<button className="btn primary" disabled={busy || !word.trim()}>추가</button>
|
||||
</form>
|
||||
<div className="dict-list">
|
||||
{words.length === 0 && <div className="dim small">아직 없습니다</div>}
|
||||
{words.map((w) => (
|
||||
<span key={w.id} className="dict-word">
|
||||
{w.word}
|
||||
<span className="dim tiny">{SRC[w.source] ?? w.source}{w.hits ? ` · ${w.hits}회` : ''}</span>
|
||||
<button aria-label="삭제" onClick={() => void run(() => api.deleteDict(w.id))}>✕</button>
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
<section className="card">
|
||||
<h3 className="h">교정 규칙 <span className="dim small">{rules.length}</span></h3>
|
||||
<form
|
||||
className="dict-form"
|
||||
onSubmit={(e) => {
|
||||
e.preventDefault();
|
||||
if (from.trim() && to.trim()) void run(async () => { await api.addRule(from.trim(), to.trim()); setFrom(''); setTo(''); });
|
||||
}}
|
||||
>
|
||||
<input placeholder="잘못 나온 말 (예: 레이저)" value={from} onChange={(e) => setFrom(e.target.value)} />
|
||||
<span className="dim">→</span>
|
||||
<input placeholder="바른 말 (예: 레이즈)" value={to} onChange={(e) => setTo(e.target.value)} />
|
||||
<button className="btn primary" disabled={busy || !from.trim() || !to.trim()}>추가</button>
|
||||
</form>
|
||||
<table className="dict-table">
|
||||
<tbody>
|
||||
{rules.map((r) => (
|
||||
<tr key={r.id}>
|
||||
<td className="from">{r.from}</td>
|
||||
<td className="dim">→</td>
|
||||
<td className="to">{r.word}</td>
|
||||
<td><span className={`badge src-${r.source}`}>{SRC[r.source] ?? r.source}</span></td>
|
||||
<td>{r.source !== 'builtin' && <button className="link" onClick={() => void run(() => api.deleteDict(r.id))}>삭제</button>}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user