fix(kline): auto-load more history when data doesn't fill screen

- Always assume hasMoreHistory=true on initial load
- Auto-trigger loadMoreHistory when klines don't fill drawable area
- This ensures sparse data periods load all available history

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-19 22:53:48 -08:00
parent 84d920f98f
commit 9333cd81c3
3 changed files with 21 additions and 2 deletions

View File

@ -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": []

View File

@ -113,7 +113,7 @@ class KlinesNotifier extends StateNotifier<KlinesState> {
state = state.copyWith(
klines: klines,
isLoading: false,
hasMoreHistory: klines.length >= 100, // 100
hasMoreHistory: true, //
);
_startAutoRefresh(apiPeriod);
},

View File

@ -97,6 +97,24 @@ class _KlineChartWidgetState extends State<KlineChartWidget> {
// 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 线