debug(frontend): 添加资产页面定时器调试日志

添加 debugPrint 日志帮助定位1秒刷新不生效的问题

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-17 22:49:46 -08:00
parent d8dd38e91b
commit 33233901a9
1 changed files with 16 additions and 1 deletions

View File

@ -48,7 +48,10 @@ class _AssetPageState extends ConsumerState<AssetPage> {
/// 使
void _startTimerWithGrowth(AssetDisplay asset, String perSecondEarning) {
//
if (_timerStarted && _refreshTimer != null) return;
if (_timerStarted && _refreshTimer != null) {
debugPrint('[AssetPage] Timer already started, skipping');
return;
}
_refreshTimer?.cancel();
_elapsedSeconds = 0;
@ -58,11 +61,14 @@ class _AssetPageState extends ConsumerState<AssetPage> {
_growthPerSecond = double.tryParse(perSecondEarning) ?? 0;
_timerStarted = true;
debugPrint('[AssetPage] Starting timer: perSecondEarning=$perSecondEarning, growthPerSecond=$_growthPerSecond, initialDisplayValue=$_initialDisplayValue');
_refreshTimer = Timer.periodic(const Duration(seconds: 1), (timer) {
if (mounted) {
setState(() {
_elapsedSeconds++;
});
debugPrint('[AssetPage] Timer tick: $_elapsedSeconds, currentDisplayValue=$_currentDisplayValue');
}
});
}
@ -105,10 +111,15 @@ class _AssetPageState extends ConsumerState<AssetPage> {
final perSecondEarning = shareAccount?.perSecondEarning ?? '0';
final hasValidGrowth = (double.tryParse(perSecondEarning) ?? 0) > 0;
//
debugPrint('[AssetPage] build: accountSequence=$accountSequence, asset=${asset != null}, shareAccount=${shareAccount != null}');
debugPrint('[AssetPage] build: perSecondEarning=$perSecondEarning, hasValidGrowth=$hasValidGrowth, _timerStarted=$_timerStarted, _lastAccountSequence=$_lastAccountSequence');
//
if (asset != null && hasValidGrowth) {
//
if (_lastAccountSequence != accountSequence) {
debugPrint('[AssetPage] Account changed or first load, resetting timer');
_lastAccountSequence = accountSequence;
_lastAsset = asset;
_resetTimer();
@ -117,6 +128,7 @@ class _AssetPageState extends ConsumerState<AssetPage> {
});
} else if (!_timerStarted) {
//
debugPrint('[AssetPage] Timer not started, starting now');
_lastAsset = asset;
WidgetsBinding.instance.addPostFrameCallback((_) {
if (mounted) _startTimerWithGrowth(asset, perSecondEarning);
@ -125,7 +137,10 @@ class _AssetPageState extends ConsumerState<AssetPage> {
_lastAsset = asset;
}
} else if (asset != null) {
debugPrint('[AssetPage] Asset loaded but no valid growth: perSecondEarning=$perSecondEarning');
_lastAsset = asset;
} else {
debugPrint('[AssetPage] Asset is null, waiting for data');
}
return Scaffold(