简化泥点余额展示分支
提取泥点余额格式化函数,移除统计卡中的嵌套三元表达式。
This commit is contained in:
@@ -243,6 +243,19 @@ function formatDashboardCount(value: number) {
|
||||
return Math.max(0, Math.round(value)).toLocaleString('zh-CN');
|
||||
}
|
||||
|
||||
function formatWalletBalance(
|
||||
balance: ProfileMudPointBalance | null,
|
||||
isLoading: boolean,
|
||||
) {
|
||||
if (balance) {
|
||||
return formatDashboardCount(balance.totalPoints);
|
||||
}
|
||||
if (isLoading) {
|
||||
return '读取中';
|
||||
}
|
||||
return '暂不可用';
|
||||
}
|
||||
|
||||
function formatTotalPlayTime(value: number) {
|
||||
const hours = Math.max(0, Math.round(value / 360000) / 10);
|
||||
return `${hours.toLocaleString('zh-CN', {
|
||||
@@ -547,13 +560,10 @@ export function PlatformActiveProfileView({
|
||||
<ProfileStatCard
|
||||
cardKey="wallet"
|
||||
label="泥点余额"
|
||||
value={
|
||||
mudPointBalance
|
||||
? formatDashboardCount(mudPointBalance.totalPoints)
|
||||
: isLoadingWalletBalance
|
||||
? '读取中'
|
||||
: '暂不可用'
|
||||
}
|
||||
value={formatWalletBalance(
|
||||
mudPointBalance,
|
||||
isLoadingWalletBalance,
|
||||
)}
|
||||
icon={Coins}
|
||||
imageSrc={profilePointImage}
|
||||
onClick={onOpenWalletLedger}
|
||||
|
||||
Reference in New Issue
Block a user