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); }