style(mining-admin-web): display all numbers with 8 decimal places

Update all formatDecimal, formatNumber, formatPercent, formatCompactNumber
and formatShareAmount calls to use 8 decimal precision for consistent display
across all pages (dashboard, users, reports, system-accounts).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-15 02:55:23 -08:00
parent d7bbb19571
commit 1bdb9bb336
13 changed files with 49 additions and 49 deletions

View File

@ -123,8 +123,8 @@ export default function ReportsPage() {
<TableCell className="text-right font-mono text-green-600">
+{formatCompactNumber(report.newContribution)}
</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(report.dailyDistributed, 2)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(report.dailyBurned, 2)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(report.dailyDistributed, 8)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(report.dailyBurned, 8)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(report.closePrice, 8)}</TableCell>
<TableCell className="text-right font-mono">{formatCompactNumber(report.dailyVolume)}</TableCell>
</TableRow>

View File

@ -193,14 +193,14 @@ export default function UserDetailPage() {
{/* 个人算力 */}
<div className="flex justify-between items-center">
<span className="text-sm text-muted-foreground"> (70%)</span>
<span className="font-mono font-medium">{formatDecimal(user?.contributions?.personal, 4)}</span>
<span className="font-mono font-medium">{formatDecimal(user?.contributions?.personal, 8)}</span>
</div>
{/* 层级算力 */}
<div className="space-y-2">
<div className="flex justify-between items-center">
<span className="text-sm text-muted-foreground"> (7.5%)</span>
<span className="font-mono font-medium">{formatDecimal(user?.contributions?.teamLevel, 4)}</span>
<span className="font-mono font-medium">{formatDecimal(user?.contributions?.teamLevel, 8)}</span>
</div>
<div className="pl-3 space-y-1 text-xs">
<div className="flex items-center gap-2">
@ -243,7 +243,7 @@ export default function UserDetailPage() {
<div className="space-y-2">
<div className="flex justify-between items-center">
<span className="text-sm text-muted-foreground"> (7.5%)</span>
<span className="font-mono font-medium">{formatDecimal(user?.contributions?.teamBonus, 4)}</span>
<span className="font-mono font-medium">{formatDecimal(user?.contributions?.teamBonus, 8)}</span>
</div>
<div className="pl-3 space-y-1 text-xs">
<div className="flex items-center gap-2">
@ -285,7 +285,7 @@ export default function UserDetailPage() {
{/* 有效算力 */}
<div className="flex justify-between pt-3 border-t font-medium">
<span> ()</span>
<span className="font-mono text-primary text-lg">{formatDecimal(user?.effectiveContribution, 4)}</span>
<span className="font-mono text-primary text-lg">{formatDecimal(user?.effectiveContribution, 8)}</span>
</div>
{/* 解锁状态汇总 */}
@ -317,7 +317,7 @@ export default function UserDetailPage() {
<Coins className="h-4 w-4" />
</p>
<p className="text-3xl font-bold font-mono text-primary mt-1">
{formatDecimal(user?.miningBalance, 4)}
{formatDecimal(user?.miningBalance, 8)}
</p>
</div>
</div>
@ -331,7 +331,7 @@ export default function UserDetailPage() {
<ShoppingCart className="h-4 w-4" />
</p>
<p className="text-3xl font-bold font-mono text-blue-600 mt-1">
{formatDecimal(user?.tradingBalance, 4)}
{formatDecimal(user?.tradingBalance, 8)}
</p>
</div>
</div>
@ -343,7 +343,7 @@ export default function UserDetailPage() {
<div>
<p className="text-sm text-muted-foreground"></p>
<p className="text-3xl font-bold font-mono text-orange-600 mt-1">
{formatDecimal(user?.frozenBalance, 4)}
{formatDecimal(user?.frozenBalance, 8)}
</p>
</div>
</div>

View File

@ -182,11 +182,11 @@ export default function UsersPage() {
</TableCell>
{/* 有效算力 */}
<TableCell className="text-right font-mono text-sm text-primary font-medium">
{formatDecimal(user.effectiveContribution, 4)}
{formatDecimal(user.effectiveContribution, 8)}
</TableCell>
{/* 挖矿余额 */}
<TableCell className="text-right font-mono text-sm">
{formatDecimal(user.miningBalance, 4)}
{formatDecimal(user.miningBalance, 8)}
</TableCell>
{/* 推荐人 */}
<TableCell className="font-mono text-sm text-muted-foreground">

View File

@ -35,14 +35,14 @@ export function RealtimePanel() {
const items = [
{
label: '本分钟分配',
value: formatDecimal(data?.currentMinuteDistribution, 4),
value: formatDecimal(data?.currentMinuteDistribution, 8),
unit: '股',
icon: Activity,
iconColor: 'text-green-500',
},
{
label: '本分钟销毁',
value: formatDecimal(data?.currentMinuteBurn, 4),
value: formatDecimal(data?.currentMinuteBurn, 8),
unit: '股',
icon: Flame,
iconColor: 'text-orange-500',

View File

@ -44,7 +44,7 @@ export function AccountCard({ account }: AccountCardProps) {
)}
</div>
<p className="text-2xl font-bold font-mono mt-1">
{formatDecimal(balance, 4)}
{formatDecimal(balance, 8)}
</p>
<p className="text-xs text-muted-foreground mt-2 line-clamp-2">
{account.description || displayInfo.description}

View File

@ -94,7 +94,7 @@ export function AccountsTable({
{account.name || displayInfo.label}
</TableCell>
<TableCell className="text-right font-mono">
{formatDecimal(balance, 4)}
{formatDecimal(balance, 8)}
{account.contributionNeverExpires && (
<Badge variant="outline" className="ml-2 text-xs">

View File

@ -41,7 +41,7 @@ export function SummaryCards({ summary, isLoading = false }: SummaryCardsProps)
<p className="text-sm text-muted-foreground"></p>
<p className="text-2xl font-bold mt-1">{summary.systemAccounts.count}</p>
<p className="text-xs text-muted-foreground mt-2">
: {formatDecimal(summary.systemAccounts.totalContribution, 4)}
: {formatDecimal(summary.systemAccounts.totalContribution, 8)}
</p>
</div>
<div className="p-3 rounded-lg bg-blue-50">
@ -59,7 +59,7 @@ export function SummaryCards({ summary, isLoading = false }: SummaryCardsProps)
<p className="text-sm text-muted-foreground"></p>
<p className="text-2xl font-bold mt-1">{summary.syncedContributions.count}</p>
<p className="text-xs text-muted-foreground mt-2">
: {formatDecimal(summary.syncedContributions.totalBalance, 4)}
: {formatDecimal(summary.syncedContributions.totalBalance, 8)}
</p>
</div>
<div className="p-3 rounded-lg bg-green-50">
@ -88,7 +88,7 @@ export function SummaryCards({ summary, isLoading = false }: SummaryCardsProps)
{summary.miningConfig.currentEra}
</p>
<p className="text-xs text-muted-foreground mt-2">
: {formatDecimal(summary.miningConfig.remainingDistribution, 2)}
: {formatDecimal(summary.miningConfig.remainingDistribution, 8)}
</p>
</>
) : (
@ -111,10 +111,10 @@ export function SummaryCards({ summary, isLoading = false }: SummaryCardsProps)
{summary.circulationPool ? (
<>
<p className="text-2xl font-bold mt-1">
{formatDecimal(summary.circulationPool.totalShares, 2)}
{formatDecimal(summary.circulationPool.totalShares, 8)}
</p>
<p className="text-xs text-muted-foreground mt-2">
: {formatDecimal(summary.circulationPool.totalCash, 2)} USDT
: {formatDecimal(summary.circulationPool.totalCash, 8)} USDT
</p>
</>
) : (

View File

@ -88,9 +88,9 @@ export function ContributionRecordsList({ accountSequence }: ContributionRecords
)}
</TableCell>
<TableCell className="text-right">{record.treeCount}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(record.baseContribution, 2)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(record.baseContribution, 8)}</TableCell>
<TableCell className="text-right">{formatPercent(record.distributionRate)}</TableCell>
<TableCell className="text-right font-mono font-medium">{formatDecimal(record.amount, 4)}</TableCell>
<TableCell className="text-right font-mono font-medium">{formatDecimal(record.amount, 8)}</TableCell>
<TableCell>
{record.levelDepth !== null
? `L${record.levelDepth}`

View File

@ -56,7 +56,7 @@ export function MiningRecordsList({ accountSequence }: MiningRecordsListProps) {
<TableCell className="font-mono">{record.distributionMinute}</TableCell>
<TableCell className="text-right">{formatPercent(record.contributionRatio)}</TableCell>
<TableCell className="text-right font-mono text-primary">
+{formatDecimal(record.shareAmount, 4)}
+{formatDecimal(record.shareAmount, 8)}
</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(record.priceSnapshot, 8)}</TableCell>
<TableCell className="text-sm">{formatDateTime(record.createdAt)}</TableCell>

View File

@ -107,7 +107,7 @@ export function PlantingLedger({ accountSequence }: PlantingLedgerProps) {
</div>
<div className="text-center p-4 bg-muted rounded-lg">
<p className="text-sm text-muted-foreground"></p>
<p className="text-2xl font-bold text-primary">{formatDecimal(data.summary.totalAmount, 2)}</p>
<p className="text-2xl font-bold text-primary">{formatDecimal(data.summary.totalAmount, 8)}</p>
</div>
<div className="text-center p-4 bg-muted rounded-lg">
<p className="text-sm text-muted-foreground"></p>
@ -159,28 +159,28 @@ export function PlantingLedger({ accountSequence }: PlantingLedgerProps) {
<TableRow key={item.id || item.orderId}>
<TableCell className="font-mono text-sm">{item.originalAdoptionId || item.orderNo}</TableCell>
<TableCell className="text-right font-mono">{formatNumber(item.treeCount)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(item.contributionPerTree || '0', 4)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(item.totalContribution || item.totalAmount || '0', 4)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(item.contributionPerTree || '0', 8)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(item.totalContribution || item.totalAmount || '0', 8)}</TableCell>
<TableCell>
{item.distribution ? (
<div className="text-xs space-y-0.5">
<div className="text-green-600">
{(item.distribution.personal.rate * 100).toFixed(0)}%{formatDecimal(item.distribution.personal.amount, 2)}{item.distribution.personal.label}
{(item.distribution.personal.rate * 100).toFixed(0)}%{formatDecimal(item.distribution.personal.amount, 8)}{item.distribution.personal.label}
</div>
<div className="text-blue-600">
{(item.distribution.operation.rate * 100).toFixed(0)}%{formatDecimal(item.distribution.operation.amount, 2)}{item.distribution.operation.label}
{(item.distribution.operation.rate * 100).toFixed(0)}%{formatDecimal(item.distribution.operation.amount, 8)}{item.distribution.operation.label}
</div>
<div className="text-blue-600">
{(item.distribution.province.rate * 100).toFixed(0)}%{formatDecimal(item.distribution.province.amount, 2)}{item.distribution.province.label}
{(item.distribution.province.rate * 100).toFixed(0)}%{formatDecimal(item.distribution.province.amount, 8)}{item.distribution.province.label}
</div>
<div className="text-blue-600">
{(item.distribution.city.rate * 100).toFixed(0)}%{formatDecimal(item.distribution.city.amount, 2)}{item.distribution.city.label}
{(item.distribution.city.rate * 100).toFixed(0)}%{formatDecimal(item.distribution.city.amount, 8)}{item.distribution.city.label}
</div>
<div className="text-orange-600">
{(item.distribution.team.rate * 100).toFixed(0)}%{formatDecimal(item.distribution.team.amount, 2)}{item.distribution.team.label}
{(item.distribution.team.rate * 100).toFixed(0)}%{formatDecimal(item.distribution.team.amount, 8)}{item.distribution.team.label}
{item.distribution.team.distributed && (
<span className="text-muted-foreground ml-1">
[:{formatDecimal(item.distribution.team.distributed, 2)} / :{formatDecimal(item.distribution.team.unallocated, 2)}]
[:{formatDecimal(item.distribution.team.distributed, 8)} / :{formatDecimal(item.distribution.team.unallocated, 8)}]
</span>
)}
</div>

View File

@ -80,8 +80,8 @@ export function TradeOrdersList({ accountSequence }: TradeOrdersListProps) {
</span>
</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(order.price, 8)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(order.quantity, 4)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(order.filledQuantity, 4)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(order.quantity, 8)}</TableCell>
<TableCell className="text-right font-mono">{formatDecimal(order.filledQuantity, 8)}</TableCell>
<TableCell className="text-sm">{formatDateTime(order.createdAt)}</TableCell>
</TableRow>
);

View File

@ -111,37 +111,37 @@ export function WalletLedger({ accountSequence }: WalletLedgerProps) {
<div className="text-center p-4 bg-muted rounded-lg">
<p className="text-sm text-muted-foreground">绿 </p>
<p className="text-2xl font-bold text-green-600 font-mono">
{formatDecimal(data.summary.usdtAvailable, 4)}
{formatDecimal(data.summary.usdtAvailable, 8)}
</p>
</div>
<div className="text-center p-4 bg-muted rounded-lg">
<p className="text-sm text-muted-foreground">绿 </p>
<p className="text-2xl font-bold text-orange-600 font-mono">
{formatDecimal(data.summary.usdtFrozen, 4)}
{formatDecimal(data.summary.usdtFrozen, 8)}
</p>
</div>
<div className="text-center p-4 bg-muted rounded-lg">
<p className="text-sm text-muted-foreground"></p>
<p className="text-2xl font-bold text-yellow-600 font-mono">
{formatDecimal(data.summary.pendingUsdt, 4)}
{formatDecimal(data.summary.pendingUsdt, 8)}
</p>
</div>
<div className="text-center p-4 bg-muted rounded-lg">
<p className="text-sm text-muted-foreground"></p>
<p className="text-2xl font-bold text-blue-600 font-mono">
{formatDecimal(data.summary.settleableUsdt, 4)}
{formatDecimal(data.summary.settleableUsdt, 8)}
</p>
</div>
<div className="text-center p-4 bg-muted rounded-lg">
<p className="text-sm text-muted-foreground"></p>
<p className="text-2xl font-bold text-primary font-mono">
{formatDecimal(data.summary.settledTotalUsdt, 4)}
{formatDecimal(data.summary.settledTotalUsdt, 8)}
</p>
</div>
<div className="text-center p-4 bg-muted rounded-lg">
<p className="text-sm text-muted-foreground"></p>
<p className="text-2xl font-bold text-muted-foreground font-mono">
{formatDecimal(data.summary.expiredTotalUsdt, 4)}
{formatDecimal(data.summary.expiredTotalUsdt, 8)}
</p>
</div>
</div>
@ -201,11 +201,11 @@ export function WalletLedger({ accountSequence }: WalletLedgerProps) {
<TrendingDown className="h-3 w-3" />
)}
{isPositive ? '+' : ''}
{formatDecimal(item.amount, 4)}
{formatDecimal(item.amount, 8)}
</span>
</TableCell>
<TableCell className="text-right font-mono text-sm">
{formatDecimal(item.balanceAfter, 4)}
{formatDecimal(item.balanceAfter, 8)}
</TableCell>
<TableCell className="font-mono text-xs text-muted-foreground max-w-[120px] truncate">
{item.refOrderId || item.refTxHash || '-'}

View File

@ -1,6 +1,6 @@
import Decimal from 'decimal.js';
export function formatNumber(value: number | string | undefined | null, decimals = 0): string {
export function formatNumber(value: number | string | undefined | null, decimals = 8): string {
if (value === undefined || value === null) return '-';
const num = typeof value === 'string' ? parseFloat(value) : value;
if (isNaN(num)) return '-';
@ -21,7 +21,7 @@ export function formatDecimal(value: string | number | undefined | null, precisi
}
}
export function formatPercent(value: number | string | undefined | null, decimals = 2): string {
export function formatPercent(value: number | string | undefined | null, decimals = 8): string {
if (value === undefined || value === null) return '-';
const num = typeof value === 'string' ? parseFloat(value) : value;
if (isNaN(num)) return '-';
@ -33,10 +33,10 @@ export function formatCompactNumber(value: number | string | undefined | null):
const num = typeof value === 'string' ? parseFloat(value) : value;
if (isNaN(num)) return '-';
if (num >= 1e12) return `${(num / 1e12).toFixed(2)}万亿`;
if (num >= 1e8) return `${(num / 1e8).toFixed(2)}亿`;
if (num >= 1e4) return `${(num / 1e4).toFixed(2)}`;
return formatNumber(num);
if (num >= 1e12) return `${(num / 1e12).toFixed(8)}万亿`;
if (num >= 1e8) return `${(num / 1e8).toFixed(8)}亿`;
if (num >= 1e4) return `${(num / 1e4).toFixed(8)}`;
return formatNumber(num, 8);
}
export function formatPrice(value: string | number | undefined | null): string {
@ -44,5 +44,5 @@ export function formatPrice(value: string | number | undefined | null): string {
}
export function formatShareAmount(value: string | number | undefined | null): string {
return formatDecimal(value, 4);
return formatDecimal(value, 8);
}