From 4bb5a2b09dcad1eae5085cce4201ecbc315e09ad Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 18 Jan 2026 04:28:30 -0800 Subject: [PATCH] =?UTF-8?q?refactor(frontend):=20=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=98=BE=E7=A4=BA=E5=AE=9E=E9=99=85=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E8=82=A1=E5=92=8C=E4=BB=B7=E6=A0=BC=EF=BC=8C=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=80=8D=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 资产显示值改为 积分股余额 × price(不含倍数) - 显示实际积分股数量而非含倍数的有效积分股 - 简化实时计算逻辑 Co-Authored-By: Claude Opus 4.5 --- .../presentation/pages/asset/asset_page.dart | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/frontend/mining-app/lib/presentation/pages/asset/asset_page.dart b/frontend/mining-app/lib/presentation/pages/asset/asset_page.dart index 62f102d4..33853b9e 100644 --- a/frontend/mining-app/lib/presentation/pages/asset/asset_page.dart +++ b/frontend/mining-app/lib/presentation/pages/asset/asset_page.dart @@ -33,7 +33,6 @@ class _AssetPageState extends ConsumerState { // 实时刷新相关状态 Timer? _refreshTimer; int _elapsedSeconds = 0; - double _initialDisplayValue = 0; double _initialShareBalance = 0; double _growthPerSecond = 0; String? _lastAccountSequence; @@ -54,7 +53,6 @@ class _AssetPageState extends ConsumerState { _refreshTimer?.cancel(); _elapsedSeconds = 0; - _initialDisplayValue = double.tryParse(asset.displayAssetValue) ?? 0; _initialShareBalance = double.tryParse(asset.shareBalance) ?? 0; // 使用传入的每秒增长值(来自 mining-service) _growthPerSecond = double.tryParse(perSecondEarning) ?? 0; @@ -78,13 +76,10 @@ class _AssetPageState extends ConsumerState { } /// 计算当前实时资产显示值 - /// 资产显示值 = 积分股余额 × (1 + burnMultiplier) × price - /// 每秒资产增长 = 每秒积分股增长 × (1 + burnMultiplier) × price + /// 资产显示值 = 积分股余额 × price(不含倍数,使用实际价格) double get _currentDisplayValue { final price = double.tryParse(_lastAsset?.currentPrice ?? '0') ?? 0; - final burnMultiplier = double.tryParse(_lastAsset?.burnMultiplier ?? '0') ?? 0; - final multiplierFactor = 1 + burnMultiplier; - return _initialDisplayValue + (_elapsedSeconds * _growthPerSecond * multiplierFactor * price); + return _currentShareBalance * price; } /// 计算当前实时积分股余额 @@ -163,7 +158,7 @@ class _AssetPageState extends ConsumerState { children: [ const SizedBox(height: 8), // 总资产卡片 - 始终显示,数字部分闪烁,实时刷新 - _buildTotalAssetCard(asset, isLoading, _currentDisplayValue, perSecondEarning), + _buildTotalAssetCard(asset, isLoading, _currentDisplayValue, _currentShareBalance, perSecondEarning), const SizedBox(height: 24), // 快捷操作按钮 _buildQuickActions(context), @@ -208,14 +203,19 @@ class _AssetPageState extends ConsumerState { ); } - Widget _buildTotalAssetCard(AssetDisplay? asset, bool isLoading, double currentDisplayValue, String perSecondEarning) { + Widget _buildTotalAssetCard(AssetDisplay? asset, bool isLoading, double currentDisplayValue, double currentShareBalance, String perSecondEarning) { // 使用传入的每秒增长值(来自 mining-service) final growthPerSecond = double.tryParse(perSecondEarning) ?? 0.0; - // 使用实时计算的资产值(如果有) + // 使用实时计算的资产值(如果有)- 不含倍数 final displayValue = asset != null && currentDisplayValue > 0 ? currentDisplayValue.toString() - : asset?.displayAssetValue; + : null; + + // 使用实时计算的积分股余额(如果有)- 实际数量,不含倍数 + final shareBalance = asset != null && currentShareBalance > 0 + ? currentShareBalance.toString() + : asset?.shareBalance; return Container( decoration: BoxDecoration( @@ -300,9 +300,9 @@ class _AssetPageState extends ConsumerState { ), ), const SizedBox(height: 4), - // 有效积分股 + // 积分股余额 - 实际数量 DataText( - data: asset != null ? '≈ ${formatCompact(asset.effectiveShares)} 积分股 (含倍数)' : null, + data: shareBalance != null ? '≈ ${formatCompact(shareBalance)} 积分股' : null, isLoading: isLoading, placeholder: '≈ -- 积分股', style: const TextStyle(