"use client" import { COLORS } from "@/components/logic" interface ResultPanelProps { groups: { numbers: number[]; colorIndex: number }[] hasResult: boolean } export function ResultPanel({ groups, hasResult }: ResultPanelProps) { if (!hasResult || groups.length === 0) { return (
— AWAITING INPUT —
) } // 将groups分成pairs,每组人数>=15时单独一行 const rows: { numbers: number[]; colorIndex: number }[][] = [] let currentRow: { numbers: number[]; colorIndex: number }[] = [] for (const group of groups) { if (group.numbers.length >= 15) { // 单独一行 if (currentRow.length > 0) { rows.push(currentRow) currentRow = [] } rows.push([group]) } else { // 尝试凑成一行两组 currentRow.push(group) if (currentRow.length === 2) { rows.push(currentRow) currentRow = [] } } } // 处理剩余的组 if (currentRow.length > 0) { rows.push(currentRow) } // 预先建立索引映射 const groupIndexMap = new Map(groups.map((g, i) => [g, i])) return (
{rows.map((row, rowIdx) => (
{row.map((group) => { const sorted = [...group.numbers].sort((a, b) => a - b) const color = COLORS[group.colorIndex] const globalIdx = groupIndexMap.get(group)! return (
{/* Group label with color */}
G{String(globalIdx + 1).padStart(2, "0")}
{/* Numbers with color */}
{sorted.map((num) => ( {String(num).padStart(2, "0")} ))}
) })}
))}
) }