fix(ui): 增加 txTypeMap,实现交易流水类型中文化

This commit is contained in:
kennethcheng 2026-04-29 00:51:50 +08:00
parent ffeac757e3
commit fd529404bc
2 changed files with 12 additions and 1 deletions

View File

@ -70,6 +70,10 @@
- 修復了币种符号映射错乱 Bug`getCurrencySymbol()` 中 CNY 和 HKD 被错误地映射为 `HK$`,现修正为 USD→$、HKD→HK$、CNY→¥。
- 在 portfolio 引擎中新增了单资产的流水明细数组:`Position` 接口新增 `transactions` 字段,`getPortfolioPositions()` 按资产名下发排序后的原始交易流水,支持前端展开查看。
## 流水交易類型中文化映射 (Task 42a)
- 在 `app/dashboard/page.tsx` 中新增 `txTypeMap` 字典,將 `BUY`/`SELL`/`DIVIDEND`/`AIRDROP` 映射為對應中文(買入/賣出/分紅/空投)。
- 流水明細子表格中渲染 `tx.txType` 的邏輯替換為 `{txTypeMap[tx.txType] || tx.txType}`,保留原始值兜底。
## 持倉引擎 Native 幣種算法重構 (Task 38)
- 重構底層盈虧引擎,全面轉向 Native 原生幣種計算,新增浮動/累計盈虧及百分比指標。
- 徹底分離 Native 與 CNY 計算:單隻股票的成本與盈虧全部改用 Native (原幣種) 進行計算。

View File

@ -31,6 +31,13 @@ import { deleteTransaction } from '@/actions/transaction';
import { ChevronDown, ChevronUp, Plus, Edit3, Trash2 } from 'lucide-react';
import Big from 'big.js';
const txTypeMap: Record<string, string> = {
BUY: '买入',
SELL: '卖出',
DIVIDEND: '分红',
AIRDROP: '空投',
};
function getCurrencySymbol(currency: string): string {
if (currency === 'USD') return '$';
if (currency === 'HKD') return 'HK$';
@ -303,7 +310,7 @@ export default function DashboardPage() {
tx.txType === 'AIRDROP' ? 'bg-purple-100 text-purple-700' :
'bg-gray-100 text-gray-700'
}`}>
{tx.txType}
{txTypeMap[tx.txType] || tx.txType}
</span>
</TableCell>
<TableCell className="text-right text-xs">