From 8f169badee5c090f2386e2113b230c0c3eef3c1e Mon Sep 17 00:00:00 2001 From: JianMiau Date: Thu, 6 Jun 2024 16:03:12 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E6=B2=92=E6=BB=BF21=E5=88=86bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Play.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Play.tsx b/src/Play.tsx index 2a1ef82..58665c7 100644 --- a/src/Play.tsx +++ b/src/Play.tsx @@ -49,13 +49,19 @@ export default function Play() { useEffect(() => { if (data) { const score: number[] = JSON.parse(data.score); - const win: number = score.indexOf(data.winScore); + const win: number = score.indexOf(data.winScore) === -1 + ? score.indexOf(score[0] > score[1] ? score[0] : score[1]) + : score.indexOf(data.winScore); const team: string[] = JSON.parse(data.team).flat(); const winTeam: string[] = JSON.parse(data.team)[win]; const scoreList: number[] = JSON.parse(data.scoreList); setTime(dayjs(data.time * 1000).format("YYYY-MM-DD HH:mm:ss")); setTeam(team); - setWinTeam(winTeam[0] + "、" + winTeam[1]); + if (win === -1) { + setWinTeam("不明"); + } else { + setWinTeam(winTeam[0] + "、" + winTeam[1]); + } setScore(score[0] + ":" + score[1]); setScoreList(scoreList); }