diff --git a/components/match-card-league.tsx b/components/match-card-league.tsx index 1140560..395eee2 100644 --- a/components/match-card-league.tsx +++ b/components/match-card-league.tsx @@ -38,6 +38,7 @@ export function MatchCardLeague({ setIsFav(match.fav); }, [match.fav]); + const isTennis = match.sportId === 3; const isDark = theme === "dark"; const textColor = isDark ? Colors.dark.text : Colors.light.text; const secondaryText = isDark ? "#8E8E93" : "#6B7280"; @@ -86,7 +87,29 @@ export function MatchCardLeague({ }; const scoreParts = React.useMemo(() => { - const s = (match.scoreText || "").trim(); + let s = (match.scoreText || "").trim(); + + // 对于网球,如果 scoreText 为空或 -,尝试从 scores 字段获取 + if (isTennis && (s === "" || s === "-")) { + try { + const scoresArr = typeof (match as any).scores === 'string' + ? JSON.parse((match as any).scores || "[]") + : (match as any).scores; + if (Array.isArray(scoresArr) && scoresArr.length > 0) { + const lastSet = scoresArr[scoresArr.length - 1]; + const h = parseInt(lastSet.score_first, 10); + const a = parseInt(lastSet.score_second, 10); + return { + home: lastSet.score_first || "0", + away: lastSet.score_second || "0", + hasScore: true, + homeLead: Number.isFinite(h) && Number.isFinite(a) && h > a, + awayLead: Number.isFinite(h) && Number.isFinite(a) && a > h, + }; + } + } catch (e) { } + } + const m = s.match(/(\d+)\s*[-:]\s*(\d+)/); if (m) { const homeNum = parseInt(m[1], 10); @@ -157,29 +180,37 @@ export function MatchCardLeague({ - {match.home || match.homeTeamName} + {isTennis ? (match as any).eventFirstPlayer : (match.home || match.homeTeamName)} - {showCards && homeYellowCards > 0 && } - {showCards && homeRedCards > 0 && } + {!isTennis && showCards && homeYellowCards > 0 && } + {!isTennis && showCards && homeRedCards > 0 && } - {match.away || match.awayTeamName} + {isTennis ? (match as any).eventSecondPlayer : (match.away || match.awayTeamName)} - {showCards && awayYellowCards > 0 && } - {showCards && awayRedCards > 0 && } + {!isTennis && showCards && awayYellowCards > 0 && } + {!isTennis && showCards && awayRedCards > 0 && }