From 953db2ed3feca4dbf1601ebceaac8ed2df967bfd Mon Sep 17 00:00:00 2001 From: hzj <1304805162@qq.com> Date: Fri, 16 Jan 2026 20:24:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=96=B0=E5=86=85=E5=AE=B9=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96=E5=B7=A5=E5=85=B7):=20=E5=A5=96=E5=8A=B1?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/rewardFormatter.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/utils/rewardFormatter.js diff --git a/src/utils/rewardFormatter.js b/src/utils/rewardFormatter.js new file mode 100644 index 0000000..15c07fe --- /dev/null +++ b/src/utils/rewardFormatter.js @@ -0,0 +1,22 @@ +/** + * 奖励内容格式化工具 + */ + +/** + * 格式化奖励的展示信息 + * @param {string} type - 奖励类型 (GOLD, DIAMOND, GIFT, FRAGMENTS, DOLLARS 等) + * @param {object} reward - 奖励对象 + * @returns {string} 格式化后的奖励展示文本 + */ +export const formatRewardDisplay = (type, reward) => { + const showAmountTypes = ['GOLD', 'DIAMOND', 'GIFT', 'FRAGMENTS', 'TICKET'] + + if (showAmountTypes.includes(type)) { + return reward.content || '' + } else if (type === 'DOLLARS') { + return `$${reward.content}` + } else { + // 默认返回数量加天数格式 + return `${reward.quantity}Days` + } +}