fix: 加扣分显示模式下缺少字段时回退显示总分

This commit is contained in:
JSR
2026-03-27 20:48:22 +08:00
parent 24e909a2ff
commit 473bf5f8aa
+7 -2
View File
@@ -824,11 +824,14 @@ ORDER BY reward_points DESC, score DESC`,
const avatarText = getAvatarText(item.name) const avatarText = getAvatarText(item.name)
const rankBadge = index === 0 ? "🥇" : index === 1 ? "🥈" : index === 2 ? "🥉" : null const rankBadge = index === 0 ? "🥇" : index === 1 ? "🥈" : index === 2 ? "🥉" : null
const useSplitScore = list.scoreDisplayMode === "split" const useSplitScore = list.scoreDisplayMode === "split"
const hasSplitScore = item.addScore !== undefined || item.deductScore !== undefined
const primaryMetric = useSplitScore const primaryMetric = useSplitScore
? item.addScore !== undefined ? item.addScore !== undefined
? { label: t("board.metrics.addScore"), value: item.addScore } ? { label: t("board.metrics.addScore"), value: item.addScore }
: item.deductScore !== undefined : item.deductScore !== undefined
? { label: t("board.metrics.deductScore"), value: item.deductScore } ? { label: t("board.metrics.deductScore"), value: item.deductScore }
: item.score !== undefined
? { label: t("board.metrics.totalScore"), value: item.score }
: item.rewardPoints !== undefined : item.rewardPoints !== undefined
? { label: t("board.metrics.rewardPoints"), value: item.rewardPoints } ? { label: t("board.metrics.rewardPoints"), value: item.rewardPoints }
: item.weekChange !== undefined : item.weekChange !== undefined
@@ -991,12 +994,14 @@ ORDER BY reward_points DESC, score DESC`,
{item.name} {item.name}
</div> </div>
<div style={{ marginTop: 4, display: "flex", flexWrap: "wrap", gap: 6 }}> <div style={{ marginTop: 4, display: "flex", flexWrap: "wrap", gap: 6 }}>
{list.scoreDisplayMode === "total" && item.score !== undefined && ( {(list.scoreDisplayMode === "total" ||
(list.scoreDisplayMode === "split" && !hasSplitScore)) &&
item.score !== undefined && (
<Tag color={item.score >= 0 ? "success" : "error"} style={{ margin: 0 }}> <Tag color={item.score >= 0 ? "success" : "error"} style={{ margin: 0 }}>
{t("board.metrics.totalScore")}:{" "} {t("board.metrics.totalScore")}:{" "}
{item.score > 0 ? `+${item.score}` : item.score} {item.score > 0 ? `+${item.score}` : item.score}
</Tag> </Tag>
)} )}
{list.scoreDisplayMode === "split" && item.addScore !== undefined && ( {list.scoreDisplayMode === "split" && item.addScore !== undefined && (
<Tag color="success" style={{ margin: 0 }}> <Tag color="success" style={{ margin: 0 }}>
{t("board.metrics.addScore")}:{" "} {t("board.metrics.addScore")}:{" "}