Datasets:
File size: 2,735 Bytes
5afd2f7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | import {segmentHash} from './route.ts';
import {VERIFY_BLOCKS, VERIFY_COLORS, VERIFY_LABELS, evidenceURL, reviewSegmentId} from './verify.ts';
import type {VerifyReport, VerifySegment} from './verify.ts';
function Evidence({run, paths}: {run: string; paths: string[]}) {
return <ul>{paths.map(path => <li key={path}><a href={evidenceURL(run, path)} target="_blank" rel="noopener noreferrer">{path} ↗</a></li>)}</ul>;
}
export function VerifyDetails({report, row}: {report: VerifyReport; row: VerifySegment}) {
const id = reviewSegmentId(report, row);
return <div>{id && <p><a className="btn" href={segmentHash(id)}>审剧本</a> <a className="btn" href={'/evidence/evidence.html?' + new URLSearchParams({segment: id})}>审题</a></p>}
{VERIFY_BLOCKS.map(([key, label]) => {
const block = row.checks[key];
return <section className="card" key={key}><h3>{label} <span className={'chip ' + VERIFY_COLORS[block.status]}>{VERIFY_LABELS[block.status]}</span></h3><p>{block.summary}</p>
{block.details !== null && <details><summary>详细记录(JSON)</summary><pre>{JSON.stringify(block.details, null, 2)}</pre></details>}
{block.log_tail && <details open><summary>日志末 20 行</summary><pre>{block.log_tail}</pre></details>}
<Evidence run={report.run_id} paths={block.evidence}/></section>;
})}</div>;
}
export function VerifyTable({report, expanded, onSelect}: {report: VerifyReport; expanded: number | null; onSelect: (index: number | null) => void}) {
return <div className="table-scroll"><table className="segments-table"><thead><tr><th>段</th><th>世界</th><th>时长档 / 用时</th><th>人数 / 机器人</th>{VERIFY_BLOCKS.map(([key, label]) => <th key={key}>{label}</th>)}</tr></thead>
{report.segments.map(row => <tbody key={row.index}><tr><td><button className="btn" aria-expanded={expanded === row.index} onClick={() => onSelect(expanded === row.index ? null : row.index)}>{row.script_id || `第 ${row.index + 1} 段(未生成)`}</button><small>{row.state}{row.reason ? ' · ' + row.reason : ''}</small></td><td>{row.world}</td><td>{row.tier}<small>{row.seconds === null ? '用时未知' : `${row.seconds.toFixed(2)} 秒`}</small></td><td>{row.n} / {row.robots}</td>{VERIFY_BLOCKS.map(([key, label]) => <td key={key}><span className={'chip ' + VERIFY_COLORS[row.checks[key].status]} title={row.checks[key].summary} aria-label={`${label}:${VERIFY_LABELS[row.checks[key].status]}`}>{VERIFY_LABELS[row.checks[key].status]}</span></td>)}</tr>
{expanded === row.index && <tr><td colSpan={9}><VerifyDetails report={report} row={row}/></td></tr>}</tbody>)}
</table>{!report.segments.length && <p className="empty">这批没有登记段。</p>}</div>;
}
|