refactor(frontend): 资产页面显示实际积分股和价格,移除倍数
- 资产显示值改为 积分股余额 × price(不含倍数) - 显示实际积分股数量而非含倍数的有效积分股 - 简化实时计算逻辑 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8319fe5e9a
commit
4bb5a2b09d
|
|
@ -33,7 +33,6 @@ class _AssetPageState extends ConsumerState<AssetPage> {
|
||||||
// 实时刷新相关状态
|
// 实时刷新相关状态
|
||||||
Timer? _refreshTimer;
|
Timer? _refreshTimer;
|
||||||
int _elapsedSeconds = 0;
|
int _elapsedSeconds = 0;
|
||||||
double _initialDisplayValue = 0;
|
|
||||||
double _initialShareBalance = 0;
|
double _initialShareBalance = 0;
|
||||||
double _growthPerSecond = 0;
|
double _growthPerSecond = 0;
|
||||||
String? _lastAccountSequence;
|
String? _lastAccountSequence;
|
||||||
|
|
@ -54,7 +53,6 @@ class _AssetPageState extends ConsumerState<AssetPage> {
|
||||||
|
|
||||||
_refreshTimer?.cancel();
|
_refreshTimer?.cancel();
|
||||||
_elapsedSeconds = 0;
|
_elapsedSeconds = 0;
|
||||||
_initialDisplayValue = double.tryParse(asset.displayAssetValue) ?? 0;
|
|
||||||
_initialShareBalance = double.tryParse(asset.shareBalance) ?? 0;
|
_initialShareBalance = double.tryParse(asset.shareBalance) ?? 0;
|
||||||
// 使用传入的每秒增长值(来自 mining-service)
|
// 使用传入的每秒增长值(来自 mining-service)
|
||||||
_growthPerSecond = double.tryParse(perSecondEarning) ?? 0;
|
_growthPerSecond = double.tryParse(perSecondEarning) ?? 0;
|
||||||
|
|
@ -78,13 +76,10 @@ class _AssetPageState extends ConsumerState<AssetPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 计算当前实时资产显示值
|
/// 计算当前实时资产显示值
|
||||||
/// 资产显示值 = 积分股余额 × (1 + burnMultiplier) × price
|
/// 资产显示值 = 积分股余额 × price(不含倍数,使用实际价格)
|
||||||
/// 每秒资产增长 = 每秒积分股增长 × (1 + burnMultiplier) × price
|
|
||||||
double get _currentDisplayValue {
|
double get _currentDisplayValue {
|
||||||
final price = double.tryParse(_lastAsset?.currentPrice ?? '0') ?? 0;
|
final price = double.tryParse(_lastAsset?.currentPrice ?? '0') ?? 0;
|
||||||
final burnMultiplier = double.tryParse(_lastAsset?.burnMultiplier ?? '0') ?? 0;
|
return _currentShareBalance * price;
|
||||||
final multiplierFactor = 1 + burnMultiplier;
|
|
||||||
return _initialDisplayValue + (_elapsedSeconds * _growthPerSecond * multiplierFactor * price);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 计算当前实时积分股余额
|
/// 计算当前实时积分股余额
|
||||||
|
|
@ -163,7 +158,7 @@ class _AssetPageState extends ConsumerState<AssetPage> {
|
||||||
children: [
|
children: [
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
// 总资产卡片 - 始终显示,数字部分闪烁,实时刷新
|
// 总资产卡片 - 始终显示,数字部分闪烁,实时刷新
|
||||||
_buildTotalAssetCard(asset, isLoading, _currentDisplayValue, perSecondEarning),
|
_buildTotalAssetCard(asset, isLoading, _currentDisplayValue, _currentShareBalance, perSecondEarning),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
// 快捷操作按钮
|
// 快捷操作按钮
|
||||||
_buildQuickActions(context),
|
_buildQuickActions(context),
|
||||||
|
|
@ -208,14 +203,19 @@ class _AssetPageState extends ConsumerState<AssetPage> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildTotalAssetCard(AssetDisplay? asset, bool isLoading, double currentDisplayValue, String perSecondEarning) {
|
Widget _buildTotalAssetCard(AssetDisplay? asset, bool isLoading, double currentDisplayValue, double currentShareBalance, String perSecondEarning) {
|
||||||
// 使用传入的每秒增长值(来自 mining-service)
|
// 使用传入的每秒增长值(来自 mining-service)
|
||||||
final growthPerSecond = double.tryParse(perSecondEarning) ?? 0.0;
|
final growthPerSecond = double.tryParse(perSecondEarning) ?? 0.0;
|
||||||
|
|
||||||
// 使用实时计算的资产值(如果有)
|
// 使用实时计算的资产值(如果有)- 不含倍数
|
||||||
final displayValue = asset != null && currentDisplayValue > 0
|
final displayValue = asset != null && currentDisplayValue > 0
|
||||||
? currentDisplayValue.toString()
|
? currentDisplayValue.toString()
|
||||||
: asset?.displayAssetValue;
|
: null;
|
||||||
|
|
||||||
|
// 使用实时计算的积分股余额(如果有)- 实际数量,不含倍数
|
||||||
|
final shareBalance = asset != null && currentShareBalance > 0
|
||||||
|
? currentShareBalance.toString()
|
||||||
|
: asset?.shareBalance;
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|
@ -300,9 +300,9 @@ class _AssetPageState extends ConsumerState<AssetPage> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
// 有效积分股
|
// 积分股余额 - 实际数量
|
||||||
DataText(
|
DataText(
|
||||||
data: asset != null ? '≈ ${formatCompact(asset.effectiveShares)} 积分股 (含倍数)' : null,
|
data: shareBalance != null ? '≈ ${formatCompact(shareBalance)} 积分股' : null,
|
||||||
isLoading: isLoading,
|
isLoading: isLoading,
|
||||||
placeholder: '≈ -- 积分股',
|
placeholder: '≈ -- 积分股',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue