From 28726c309b3d8e770870ff2697c73155ef7dec50 Mon Sep 17 00:00:00 2001 From: xianyi Date: Thu, 22 Jan 2026 10:12:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E7=90=83=E8=81=94=E8=B5=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/match-card-league.tsx | 49 ++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 9 deletions(-) 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 && }