diff --git a/.claude/settings.local.json b/.claude/settings.local.json index f9cf524f..8757e7bf 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -790,7 +790,8 @@ "Bash(ssh -o ProxyJump=ceshi@103.39.231.231 ceshi@192.168.1.111 \"ls -la /home/ceshi/rwadurian/backend/\")", "Bash(ssh -o ProxyJump=ceshi@103.39.231.231 ceshi@192.168.1.111 \"ls -la /home/ceshi/rwadurian/backend/services/\")", "Bash(where:*)", - "Bash(npx md-to-pdf:*)" + "Bash(npx md-to-pdf:*)", + "Bash(ssh -J ceshi@103.39.231.231 ceshi@192.168.1.111 \"curl -s ''http://localhost:3000/api/price/klines?period=1h&limit=5'' | head -500\")" ], "deny": [], "ask": [] diff --git a/frontend/mining-app/lib/presentation/providers/trading_providers.dart b/frontend/mining-app/lib/presentation/providers/trading_providers.dart index 969e7002..95ec782b 100644 --- a/frontend/mining-app/lib/presentation/providers/trading_providers.dart +++ b/frontend/mining-app/lib/presentation/providers/trading_providers.dart @@ -113,7 +113,7 @@ class KlinesNotifier extends StateNotifier { state = state.copyWith( klines: klines, isLoading: false, - hasMoreHistory: klines.length >= 100, // 如果返回100条,可能还有更多 + hasMoreHistory: true, // 默认还有更多历史,直到加载返回空数据 ); _startAutoRefresh(apiPeriod); }, diff --git a/frontend/mining-app/lib/presentation/widgets/kline_chart/kline_chart_widget.dart b/frontend/mining-app/lib/presentation/widgets/kline_chart/kline_chart_widget.dart index 48d4b92f..2272b914 100644 --- a/frontend/mining-app/lib/presentation/widgets/kline_chart/kline_chart_widget.dart +++ b/frontend/mining-app/lib/presentation/widgets/kline_chart/kline_chart_widget.dart @@ -97,6 +97,24 @@ class _KlineChartWidgetState extends State { // 计算滚动位置,让最新K线在屏幕中心 _scrollToCenter(); + + // 如果数据不足以填满屏幕且还有更多历史数据,自动加载更多 + _checkAndLoadMoreIfNeeded(); + } + + /// 检查是否需要自动加载更多历史数据 + void _checkAndLoadMoreIfNeeded() { + if (!widget.hasMoreHistory || widget.isLoadingMore) return; + + const leftPadding = 8.0; + const rightPadding = 50.0; + final drawableWidth = _chartWidth - leftPadding - rightPadding; + final totalKlineWidth = widget.klines.length * _candleWidth; + + // 如果K线总宽度不足以填满可绘制区域,自动加载更多历史 + if (totalKlineWidth < drawableWidth) { + widget.onLoadMoreHistory?.call(); + } } /// 滚动使最新 K 线在屏幕中心显示