This commit is contained in:
dahyeon committed 2026-08-12 10:32:14 -07:00
1 parent 987ad74de0
commit 7dbbf22515
2 files changed
+51 -8

No files matched your search

+51 -8
View File
@@ -1,6 +1,7 @@
import { useEffect, useMemo, useRef, useState } from 'react' import { useEffect, useMemo, useRef, useState } from 'react'
import type { import type {
AutoReservationState, AutoReservationState,
AutoSalvoAttempt,
AutoSalvoState, AutoSalvoState,
CaptchaResult, CaptchaResult,
ClockCalibrationSettings, ClockCalibrationSettings,
@@ -14,6 +15,19 @@ import { CLOCK_CALIBRATION_DEFAULTS } from '../type/reservation'
const MAX_SALVO_ATTEMPTS = 8 const MAX_SALVO_ATTEMPTS = 8
const SALVO_STATUS_LABEL: Record<AutoSalvoAttempt['status'], string> = {
pending: '대기', firing: '전송 중', succeeded: '성공', failed: '실패', skipped: '건너뜀',
}
function DetailRow({ label, value }: { label: string; value: string }) {
return (
<>
<dt className="text-ink-muted">{label}</dt>
<dd className="text-right font-mono text-ink">{value}</dd>
</>
)
}
// 토큰 수별 기본 오프셋: 1개는 +0, 그 이상은 -50 헤지 하나 뒤로 0부터 +50씩 증가. // 토큰 수별 기본 오프셋: 1개는 +0, 그 이상은 -50 헤지 하나 뒤로 0부터 +50씩 증가.
// 1→[0] · 2→[-50,0] · 3→[-50,0,50] · 4→[-50,0,50,100] · … // 1→[0] · 2→[-50,0] · 3→[-50,0,50] · 4→[-50,0,50,100] · …
export function defaultSalvoOffsets(count: number) { export function defaultSalvoOffsets(count: number) {
@@ -143,6 +157,7 @@ export default function AutomationPanel({
const [salvoState, setSalvoState] = useState<AutoSalvoState>({ status: 'idle', stopOnSuccess: true, attempts: [] }) const [salvoState, setSalvoState] = useState<AutoSalvoState>({ status: 'idle', stopOnSuccess: true, attempts: [] })
const [salvoBusy, setSalvoBusy] = useState<'token' | 'arm' | null>(null) const [salvoBusy, setSalvoBusy] = useState<'token' | 'arm' | null>(null)
const [salvoError, setSalvoError] = useState('') const [salvoError, setSalvoError] = useState('')
const [expandedAttempts, setExpandedAttempts] = useState<number[]>([])
const previousFingerprint = useRef('') const previousFingerprint = useRef('')
const previousAutoStatus = useRef(autoState.status) const previousAutoStatus = useRef(autoState.status)
const previousSalvoStatus = useRef(salvoState.status) const previousSalvoStatus = useRef(salvoState.status)
@@ -235,6 +250,7 @@ export default function AutomationPanel({
if (previousSalvoStatus.current !== salvoState.status) { if (previousSalvoStatus.current !== salvoState.status) {
if (salvoState.status === 'succeeded' && salvoState.result) { if (salvoState.status === 'succeeded' && salvoState.result) {
onResult(salvoState.result) onResult(salvoState.result)
if (salvoState.succeededIndex !== undefined) setExpandedAttempts((current) => current.includes(salvoState.succeededIndex!) ? current : [...current, salvoState.succeededIndex!])
setTokens([]) setTokens([])
} }
previousSalvoStatus.current = salvoState.status previousSalvoStatus.current = salvoState.status
@@ -344,6 +360,7 @@ export default function AutomationPanel({
if (attemptCount === 0) return setSalvoError('캡차 토큰을 먼저 하나 이상 생성해주세요.') if (attemptCount === 0) return setSalvoError('캡차 토큰을 먼저 하나 이상 생성해주세요.')
if (!Number.isFinite(targetServerTimeMs)) return setSalvoError('실행 시각을 올바르게 입력해주세요.') if (!Number.isFinite(targetServerTimeMs)) return setSalvoError('실행 시각을 올바르게 입력해주세요.')
if (!salvoReady) return setSalvoError('일부 토큰이 목표 시각에 90초를 초과합니다. 간격을 줄이거나 토큰을 다시 생성해주세요.') if (!salvoReady) return setSalvoError('일부 토큰이 목표 시각에 90초를 초과합니다. 간격을 줄이거나 토큰을 다시 생성해주세요.')
setExpandedAttempts([])
setSalvoBusy('arm') setSalvoBusy('arm')
try { try {
if (!clock?.monitoring) setClock(await window.reservationApi.startClockMonitor()) if (!clock?.monitoring) setClock(await window.reservationApi.startClockMonitor())
@@ -504,16 +521,42 @@ export default function AutomationPanel({
{salvoState.attempts.length > 0 && ( {salvoState.attempts.length > 0 && (
<div className="mt-3 overflow-hidden rounded-xl border border-line-soft"> <div className="mt-3 overflow-hidden rounded-xl border border-line-soft">
{salvoState.attempts.map((attempt) => ( {salvoState.attempts.map((attempt) => {
<div key={attempt.index} className="flex items-center justify-between gap-3 border-b border-line-soft px-3 py-2 text-[10px] last:border-b-0"> const open = expandedAttempts.includes(attempt.index)
<span className="font-mono text-ink-muted">{attempt.offsetMs >= 0 ? '+' : ''}{attempt.offsetMs}ms{attempt.plannedSendAtMs ? ` · ${formatClock(attempt.plannedSendAtMs).split(' ').at(-1)}` : ''}</span> const completed = attempt.status === 'succeeded' || attempt.status === 'failed' || attempt.status === 'skipped'
<span className="flex items-center gap-2"> const chipClass = attempt.status === 'succeeded' ? 'bg-success/10 text-success' : attempt.status === 'failed' ? 'bg-danger/10 text-danger' : attempt.status === 'firing' ? 'bg-gold text-gold-ink' : attempt.status === 'skipped' ? 'bg-chrome text-ink-muted' : 'bg-accent/10 text-accent'
{attempt.arrivalErrorMs !== undefined && <span className="font-mono text-ink-muted">도착 {attempt.arrivalErrorMs >= 0 ? '+' : ''}{attempt.arrivalErrorMs.toFixed(0)}ms</span>} return (
{attempt.httpStatus !== undefined && <span className="font-mono text-ink-muted">{attempt.httpStatus}</span>} <div key={attempt.index} className="border-b border-line-soft last:border-b-0">
<span className={`rounded-full px-2 py-0.5 font-semibold ${attempt.status === 'succeeded' ? 'bg-success/10 text-success' : attempt.status === 'failed' ? 'bg-danger/10 text-danger' : attempt.status === 'firing' ? 'bg-gold text-gold-ink' : attempt.status === 'skipped' ? 'bg-chrome text-ink-muted' : 'bg-accent/10 text-accent'}`}>{attempt.status}</span> <button type="button" aria-expanded={open} onClick={() => setExpandedAttempts((current) => current.includes(attempt.index) ? current.filter((value) => value !== attempt.index) : [...current, attempt.index])} className="flex w-full items-center justify-between gap-3 px-3 py-2 text-left text-[10px] transition hover:bg-canvas">
<span className="flex items-center gap-2 font-mono text-ink-muted">
<span className={`inline-block text-ink-muted transition-transform ${open ? 'rotate-90' : ''}`} aria-hidden="true">›</span>
{attempt.index + 1}. {attempt.offsetMs >= 0 ? '+' : ''}{attempt.offsetMs}ms{attempt.plannedSendAtMs ? ` · ${formatClock(attempt.plannedSendAtMs).split(' ').at(-1)}` : ''}
</span> </span>
<span className="flex items-center gap-2">
{completed && attempt.arrivalErrorMs !== undefined && <span className="font-mono text-ink-muted">도착 {attempt.arrivalErrorMs >= 0 ? '+' : ''}{attempt.arrivalErrorMs.toFixed(0)}ms</span>}
{completed && attempt.httpStatus !== undefined && <span className="font-mono text-ink-muted">{attempt.httpStatus}</span>}
<span className={`rounded-full px-2 py-0.5 font-semibold ${chipClass}`}>{SALVO_STATUS_LABEL[attempt.status]}</span>
</span>
</button>
{open && (
completed ? (
<dl className="grid grid-cols-[104px_1fr] gap-x-3 gap-y-1.5 border-t border-line-soft bg-canvas px-3 py-3 text-[10px]">
{attempt.message && <DetailRow label="결과" value={attempt.message} />}
{attempt.reservationNum && <DetailRow label="예약 번호" value={attempt.reservationNum} />}
<DetailRow label="목표 서버시각" value={formatClock(attempt.effectiveTargetServerMs)} />
<DetailRow label="예정 발송" value={attempt.plannedSendAtMs === undefined ? '—' : formatClock(attempt.plannedSendAtMs)} />
<DetailRow label="실제 발송" value={attempt.actualSendAtMs === undefined ? '—' : formatClock(attempt.actualSendAtMs)} />
<DetailRow label="도착 오차" value={attempt.arrivalErrorMs === undefined ? '—' : `${attempt.arrivalErrorMs >= 0 ? '+' : ''}${attempt.arrivalErrorMs.toFixed(1)}ms`} />
<DetailRow label="응답 RTT" value={attempt.rttMs === undefined ? '—' : `${attempt.rttMs.toFixed(1)}ms`} />
<DetailRow label="HTTP 상태" value={attempt.httpStatus === undefined ? '—' : String(attempt.httpStatus)} />
</dl>
) : (
<p className="border-t border-line-soft bg-canvas px-3 py-3 text-[10px] leading-4 text-ink-muted">{attempt.status === 'firing' ? '요청을 전송하고 응답을 기다리는 중입니다.' : `이 시도는 아직 대기 중입니다. 예정 발송 ${attempt.plannedSendAtMs ? formatClock(attempt.plannedSendAtMs).split(' ').at(-1) : '계산 중'}에 실행됩니다.`}</p>
)
)}
</div> </div>
))} )
})}
</div> </div>
)} )}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

After

Width:  |  Height:  |  Size: 91 KiB