From 8bcffffaa7dbc479bc017b68254f7ae5077dad64 Mon Sep 17 00:00:00 2001
From: hzm <934585316@qq.com>
Date: Sun, 1 Mar 2026 19:51:51 +0800
Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=BD=93=E6=97=A5=E6=94=B6?=
=?UTF-8?q?=E7=9B=8A=E5=B1=95=E7=A4=BA=E7=99=BE=E5=88=86=E6=AF=94?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/components/MobileFundTable.jsx | 48 +++++++++++++++++-------------
app/components/PcFundTable.jsx | 46 ++++++++++++++++------------
app/page.jsx | 17 +++++++----
3 files changed, 67 insertions(+), 44 deletions(-)
diff --git a/app/components/MobileFundTable.jsx b/app/components/MobileFundTable.jsx
index b679d71..9e31718 100644
--- a/app/components/MobileFundTable.jsx
+++ b/app/components/MobileFundTable.jsx
@@ -88,7 +88,6 @@ function SortableRow({ row, children, isTableDragging, disabled }) {
* @param {(row: any) => void} [props.onToggleFavorite] - 添加/取消自选
* @param {(row: any) => void} [props.onRemoveFromGroup] - 从当前分组移除
* @param {(row: any, meta: { hasHolding: boolean }) => void} [props.onHoldingAmountClick] - 点击持仓金额
- * @param {(row: any) => void} [props.onHoldingProfitClick] - 点击持有收益
* @param {boolean} [props.refreshing] - 是否刷新中
* @param {string} [props.sortBy] - 排序方式,'default' 时长按行触发拖拽排序
* @param {(oldIndex: number, newIndex: number) => void} [props.onReorder] - 拖拽排序回调
@@ -101,7 +100,7 @@ export default function MobileFundTable({
onToggleFavorite,
onRemoveFromGroup,
onHoldingAmountClick,
- onHoldingProfitClick,
+ onHoldingProfitClick, // 保留以兼容调用方,表格内已不再使用点击切换
refreshing = false,
sortBy = 'default',
onReorder,
@@ -119,18 +118,15 @@ export default function MobileFundTable({
const onToggleFavoriteRef = useRef(onToggleFavorite);
const onRemoveFromGroupRef = useRef(onRemoveFromGroup);
const onHoldingAmountClickRef = useRef(onHoldingAmountClick);
- const onHoldingProfitClickRef = useRef(onHoldingProfitClick);
useEffect(() => {
onToggleFavoriteRef.current = onToggleFavorite;
onRemoveFromGroupRef.current = onRemoveFromGroup;
onHoldingAmountClickRef.current = onHoldingAmountClick;
- onHoldingProfitClickRef.current = onHoldingProfitClick;
}, [
onToggleFavorite,
onRemoveFromGroup,
onHoldingAmountClick,
- onHoldingProfitClick,
]);
const handleDragStart = (e) => setActiveId(e.active.id);
@@ -475,12 +471,23 @@ export default function MobileFundTable({
const value = original.todayProfitValue;
const hasProfit = value != null;
const cls = hasProfit ? (value > 0 ? 'up' : value < 0 ? 'down' : '') : 'muted';
+ const amountStr = hasProfit ? (info.getValue() ?? '') : '—';
+ const percentStr = original.todayProfitPercent ?? '';
return (
-
-
- {hasProfit ? (info.getValue() ?? '') : ''}
-
-
+
+
+
+ {amountStr}
+
+
+ {percentStr ? (
+
+
+ {percentStr}
+
+
+ ) : null}
+
);
},
meta: { align: 'right', cellClassName: 'profit-cell', width: columnWidthMap.todayProfit },
@@ -493,21 +500,22 @@ export default function MobileFundTable({
const value = original.holdingProfitValue;
const hasTotal = value != null;
const cls = hasTotal ? (value > 0 ? 'up' : value < 0 ? 'down' : '') : 'muted';
+ const amountStr = hasTotal ? (info.getValue() ?? '') : '—';
+ const percentStr = original.holdingProfitPercent ?? '';
return (
- {
- if (!hasTotal) return;
- e.stopPropagation?.();
- onHoldingProfitClickRef.current?.(original);
- }}
- >
+
- {hasTotal ? (info.getValue() ?? '') : ''}
+ {amountStr}
+ {percentStr ? (
+
+
+ {percentStr}
+
+
+ ) : null}
);
},
diff --git a/app/components/PcFundTable.jsx b/app/components/PcFundTable.jsx
index 7d51a0b..fc681c2 100644
--- a/app/components/PcFundTable.jsx
+++ b/app/components/PcFundTable.jsx
@@ -115,7 +115,6 @@ function SortableRow({ row, children, isTableDragging, disabled }) {
* @param {(row: any) => void} [props.onToggleFavorite] - 添加/取消自选
* @param {(row: any) => void} [props.onRemoveFromGroup] - 从当前分组移除
* @param {(row: any, meta: { hasHolding: boolean }) => void} [props.onHoldingAmountClick] - 点击持仓金额
- * @param {(row: any) => void} [props.onHoldingProfitClick] - 点击持有收益
* @param {boolean} [props.refreshing] - 是否处于刷新状态(控制删除按钮禁用态)
*/
export default function PcFundTable({
@@ -126,7 +125,7 @@ export default function PcFundTable({
onToggleFavorite,
onRemoveFromGroup,
onHoldingAmountClick,
- onHoldingProfitClick,
+ onHoldingProfitClick, // 保留以兼容调用方,表格内已不再使用点击切换
refreshing = false,
sortBy = 'default',
onReorder,
@@ -308,20 +307,17 @@ export default function PcFundTable({
const onToggleFavoriteRef = useRef(onToggleFavorite);
const onRemoveFromGroupRef = useRef(onRemoveFromGroup);
const onHoldingAmountClickRef = useRef(onHoldingAmountClick);
- const onHoldingProfitClickRef = useRef(onHoldingProfitClick);
useEffect(() => {
onRemoveFundRef.current = onRemoveFund;
onToggleFavoriteRef.current = onToggleFavorite;
onRemoveFromGroupRef.current = onRemoveFromGroup;
onHoldingAmountClickRef.current = onHoldingAmountClick;
- onHoldingProfitClickRef.current = onHoldingProfitClick;
}, [
onRemoveFund,
onToggleFavorite,
onRemoveFromGroup,
onHoldingAmountClick,
- onHoldingProfitClick,
]);
const FundNameCell = ({ info }) => {
@@ -555,10 +551,21 @@ export default function PcFundTable({
const value = original.todayProfitValue;
const hasProfit = value != null;
const cls = hasProfit ? (value > 0 ? 'up' : value < 0 ? 'down' : '') : 'muted';
+ const amountStr = hasProfit ? (info.getValue() ?? '') : '—';
+ const percentStr = original.todayProfitPercent ?? '';
return (
-
- {hasProfit ? (info.getValue() ?? '') : ''}
-
+
+
+ {amountStr}
+
+ {percentStr ? (
+
+
+ {percentStr}
+
+
+ ) : null}
+
);
},
meta: {
@@ -576,19 +583,20 @@ export default function PcFundTable({
const value = original.holdingProfitValue;
const hasTotal = value != null;
const cls = hasTotal ? (value > 0 ? 'up' : value < 0 ? 'down' : '') : 'muted';
+ const amountStr = hasTotal ? (info.getValue() ?? '') : '—';
+ const percentStr = original.holdingProfitPercent ?? '';
return (
-
{
- if (!hasTotal) return;
- e.stopPropagation?.();
- onHoldingProfitClickRef.current?.(original);
- }}
- >
-
- {hasTotal ? (info.getValue() ?? '') : ''}
+
+
+ {amountStr}
+ {percentStr ? (
+
+
+ {percentStr}
+
+
+ ) : null}
);
},
diff --git a/app/page.jsx b/app/page.jsx
index 7670bfa..f787693 100644
--- a/app/page.jsx
+++ b/app/page.jsx
@@ -778,13 +778,18 @@ export default function HomePage() {
holding && isNumber(holding.cost) && isNumber(holding.share)
? holding.cost * holding.share
: 0;
- const asPercent = !!percentModes[f.code];
+ const todayProfitPercent =
+ profitToday != null && principal > 0
+ ? `${profitToday > 0 ? '+' : profitToday < 0 ? '-' : ''}${Math.abs((profitToday / principal) * 100).toFixed(2)}%`
+ : '';
const holdingProfit =
total == null
? ''
- : (asPercent && principal > 0
- ? `${total > 0 ? '+' : total < 0 ? '-' : ''}${Math.abs((total / principal) * 100).toFixed(2)}%`
- : `${total > 0 ? '+' : total < 0 ? '-' : ''}¥${Math.abs(total).toFixed(2)}`);
+ : `${total > 0 ? '+' : total < 0 ? '-' : ''}¥${Math.abs(total).toFixed(2)}`;
+ const holdingProfitPercent =
+ total != null && principal > 0
+ ? `${total > 0 ? '+' : total < 0 ? '-' : ''}${Math.abs((total / principal) * 100).toFixed(2)}%`
+ : '';
const holdingProfitValue = total;
return {
@@ -804,12 +809,14 @@ export default function HomePage() {
holdingAmount,
holdingAmountValue,
todayProfit,
+ todayProfitPercent,
todayProfitValue,
holdingProfit,
+ holdingProfitPercent,
holdingProfitValue,
};
}),
- [displayFunds, holdings, isTradingDay, todayStr, getHoldingProfit, percentModes],
+ [displayFunds, holdings, isTradingDay, todayStr, getHoldingProfit],
);
// 自动滚动选中 Tab 到可视区域