/**
* OutcomePanel: 预测主结论 —— 比分 / 胜平负 / 置信度 / 成本。
*
* P3-1: 从 MatchPredictPanel.PredictionPanel 拆出,渲染逻辑原样搬迁。
*/
import TeamSideTag from '../../../components/TeamSideTag'
import type { Match, Prediction } from '../types'
import { OUTCOME_LABEL } from '../types'
/** 置信度细线:0~1 数值的低调可视化 */
function Meter({ value }: { value: number }) {
const pct = Math.max(0, Math.min(100, Math.round(value * 100)))
return (
)
}
/** 胜平负一行文字:选中的红字加方块标记,未选中的退灰 */
function OutcomeLine({
pick,
confidence,
}: {
pick: string | null
confidence: number | null
}) {
const options = ['1', 'X', '2'] as const
return (
{options.map(o => {
const on = pick === o
return (
{on && }
{OUTCOME_LABEL[o]}
{on && confidence !== null && (
置信 {Math.round(confidence * 100)}%
)}
)
})}
{pick && confidence !== null && (
)}
)
}
/** 预测成本展示:耗时 + token + 限流余量 */
function PredictionCost({ prediction }: { prediction: Prediction }) {
const latency = prediction.latency_ms != null ? `${(prediction.latency_ms / 1000).toFixed(1)}s` : null
const tokens = prediction.prompt_tokens != null || prediction.completion_tokens != null
? `${prediction.prompt_tokens ?? '?'}/${prediction.completion_tokens ?? '?'}`
: null
if (!latency && !tokens && prediction.rate_limit_remaining == null) return null
return (
{latency && (
⏱耗时 {latency}
)}
{tokens && (
Tokprompt/completion: {tokens}
)}
{prediction.rate_limit_remaining != null && prediction.rate_limit_remaining <= 3 && (
剩余配额: {prediction.rate_limit_remaining}/10(分钟)
)}
)
}
export function OutcomePanel({ prediction, match }: { prediction: Prediction; match: Match }) {
const homeName = match.home_team_zh || match.home_team
const awayName = match.away_team_zh || match.away_team
const degraded = prediction.status === 'degraded' || prediction.status === 'failed'
return (
<>
{!degraded && (
{prediction.pred_home_goals ?? '-'}
:
{prediction.pred_away_goals ?? '-'}
预测比分
{prediction.alt_pred_home_goals != null && prediction.alt_pred_away_goals != null && (
备选{' '}
{prediction.alt_pred_home_goals}:{prediction.alt_pred_away_goals}
)}
)}
{!degraded && (
)}
{!degraded && }
>
)
}