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: () => [],
},
});
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}`;
};
</script>
<template>
+6 -3
View File
@@ -57,19 +57,22 @@ onMounted(() => {
});
const getRing = (arrow) => {
if (!arrow) return "-";
if (arrow.ringX) return "X";
return arrow.ring ? arrow.ring : "-";
return Number(arrow.ring) || 0;
};
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) => {
data[index] = arrow;
});
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 openCoachComment = () => {
if (!isMember.value) return;