From fd529404bc4721420cff94a55b4b963d1c136dc0 Mon Sep 17 00:00:00 2001 From: kennethcheng Date: Wed, 29 Apr 2026 00:51:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E5=A2=9E=E5=8A=A0=20txTypeMap?= =?UTF-8?q?=EF=BC=8C=E5=AE=9E=E7=8E=B0=E4=BA=A4=E6=98=93=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E4=B8=AD=E6=96=87=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Memory.md | 4 ++++ app/dashboard/page.tsx | 9 ++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Memory.md b/Memory.md index 4a70c55..728680e 100644 --- a/Memory.md +++ b/Memory.md @@ -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 (原幣種) 進行計算。 diff --git a/app/dashboard/page.tsx b/app/dashboard/page.tsx index 75e8948..4ab1f97 100644 --- a/app/dashboard/page.tsx +++ b/app/dashboard/page.tsx @@ -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 = { + 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}