import type { Artist } from "@/types/artist"; import { cn } from "@/lib/cn"; interface RankCardProps { artist: Artist; /** 全榜单(用于计算与上下名的差距) */ allArtists: Artist[]; className?: string; } export default function RankCard({ artist, allArtists, className }: RankCardProps) { // 按当前票数排序后定位艺人 const sorted = [...allArtists].sort((a, b) => b.votes - a.votes); const idx = sorted.findIndex((a) => a.id === artist.id); const prev = idx > 0 ? sorted[idx - 1] : undefined; const next = idx < sorted.length - 1 ? sorted[idx + 1] : undefined; const leadOver = next ? artist.votes - next.votes : null; const trailBehind = prev ? prev.votes - artist.votes : null; const isFirst = artist.rank === 1; const inTop12 = artist.rank <= 12; return (