update:优化训练0环显示

This commit is contained in:
2026-07-31 13:52:39 +08:00
parent 07dc8a250c
commit cfdb169329
2 changed files with 17 additions and 8 deletions
+11 -5
View File
@@ -5,13 +5,19 @@ const props = defineProps({
default: () => [], default: () => [],
}, },
}); });
const getSum = (a, b, c) => { const getSum = (...arrows) => {
const sum = (Number(a) || 0) + (Number(b) || 0) + (Number(c) || 0); const recordedArrows = arrows.filter(Boolean);
return sum > 0 ? sum + "环" : "-"; if (!recordedArrows.length) return "-";
const sum = recordedArrows.reduce(
(total, arrow) => total + (Number(arrow.ring) || 0),
0
);
return `${sum}`;
}; };
const roundsName = ["第一轮", "第二轮", "第三轮", "第四轮"]; const roundsName = ["第一轮", "第二轮", "第三轮", "第四轮"];
const getShowText = (arrow = {}) => { const getShowText = (arrow) => {
return arrow.ring ? (arrow.ringX ? "X" : arrow.ring + "环") : "-"; if (!arrow) return "-";
return arrow.ringX ? "X" : `${Number(arrow.ring) || 0}`;
}; };
</script> </script>
<template> <template>
+6 -3
View File
@@ -57,19 +57,22 @@ onMounted(() => {
}); });
const getRing = (arrow) => { const getRing = (arrow) => {
if (!arrow) return "-";
if (arrow.ringX) return "X"; if (arrow.ringX) return "X";
return arrow.ring ? arrow.ring : "-"; return Number(arrow.ring) || 0;
}; };
const arrows = computed(() => { const arrows = computed(() => {
const data = new Array(props.total).fill({ ring: 0 }); const data = new Array(props.total).fill(null);
(props.result.details || []).forEach((arrow, index) => { (props.result.details || []).forEach((arrow, index) => {
data[index] = arrow; data[index] = arrow;
}); });
return data; return data;
}); });
const validArrows = computed(() => arrows.value.filter((a) => !!a.ring).length); const validArrows = computed(
() => arrows.value.filter((a) => Number(a?.ring) > 0).length
);
const isMember = computed(() => user.value.vip === true || user.value.sVip === true); const isMember = computed(() => user.value.vip === true || user.value.sVip === true);
const openCoachComment = () => { const openCoachComment = () => {
if (!isMember.value) return; if (!isMember.value) return;