diff --git a/src/components/ScorePanel2.vue b/src/components/ScorePanel2.vue index bdd6c04..c12addd 100644 --- a/src/components/ScorePanel2.vue +++ b/src/components/ScorePanel2.vue @@ -5,13 +5,19 @@ const props = defineProps({ default: () => [], }, }); -const getSum = (a, b, c) => { - const sum = (Number(a) || 0) + (Number(b) || 0) + (Number(c) || 0); - return sum > 0 ? sum + "环" : "-"; +const getSum = (...arrows) => { + const recordedArrows = arrows.filter(Boolean); + if (!recordedArrows.length) return "-"; + const sum = recordedArrows.reduce( + (total, arrow) => total + (Number(arrow.ring) || 0), + 0 + ); + return `${sum}环`; }; const roundsName = ["第一轮", "第二轮", "第三轮", "第四轮"]; -const getShowText = (arrow = {}) => { - return arrow.ring ? (arrow.ringX ? "X" : arrow.ring + "环") : "-"; +const getShowText = (arrow) => { + if (!arrow) return "-"; + return arrow.ringX ? "X" : `${Number(arrow.ring) || 0}环`; };