feat(ui): 添加 Big.js 格式化工具,优化表格数字精度展示

This commit is contained in:
2026-04-27 22:32:35 +08:00
parent eba5a68495
commit 978d8a591e
4 changed files with 39 additions and 5 deletions
+8 -5
View File
@@ -1,6 +1,7 @@
import { getAssets } from '@/actions/asset';
import { getTransactions } from '@/actions/transaction';
import { AddTransactionDialog } from '@/components/transactions/add-transaction-dialog';
import { formatAmount, formatQuantity } from '@/lib/formatters';
import {
Table,
TableBody,
@@ -25,7 +26,7 @@ export default async function TransactionsPage() {
FEE: '手续费',
};
const assetMap = new Map(assets.map((a) => [a.id, a.symbol]));
const assetMap = new Map(assets.map((a) => [a.id, { symbol: a.symbol, type: a.type }]));
return (
<div className="space-y-6">
@@ -62,14 +63,16 @@ export default async function TransactionsPage() {
</TableRow>
) : (
transactions.map((tx) => {
const symbol = assetMap.get(tx.assetId) || tx.assetId;
const assetInfo = assetMap.get(tx.assetId);
const symbol = assetInfo?.symbol || tx.assetId;
const assetType = assetInfo?.type || 'CASH';
return (
<TableRow key={tx.id}>
<TableCell className="font-medium">{symbol}</TableCell>
<TableCell>{typeLabels[tx.txType] || tx.txType}</TableCell>
<TableCell>{tx.quantity}</TableCell>
<TableCell>{tx.price}</TableCell>
<TableCell>{tx.fee}</TableCell>
<TableCell>{formatQuantity(tx.quantity, assetType)}</TableCell>
<TableCell>{formatAmount(tx.price)}</TableCell>
<TableCell>{formatAmount(tx.fee)}</TableCell>
<TableCell>{tx.txCurrency}</TableCell>
<TableCell>
{tx.executedAt