From 0cabae4edaf0982b633ae53c55569b5390724365 Mon Sep 17 00:00:00 2001 From: Justin Gu <97915@qq.com> Date: Fri, 3 Jul 2026 04:30:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(web-ui):=20=E7=BF=BB=E9=A1=B5=E6=8B=BC?= =?UTF-8?q?=E6=8E=A5=E5=90=8E=E6=8C=89=E6=97=B6=E9=97=B4=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E5=A4=8D>800=E6=A0=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=9B=BE=E8=A1=A8/=E6=88=90=E4=BA=A4=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E9=94=99=E4=B9=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻页拼接 concat 后页间时间逆序(page1=最新段,page2=更旧段), 导致 index 800 处时间从 2026 倒退到 2019。引擎/图表只正确处理前 800 根, 成交记录在 800 根后出现 2019 年数据。 修复:concat 后加 sort((a,b) => datetime.localeCompare)。 实测 1600 根排序后整体时间正序,index 799→800 连续递增。 --- web-ui/src/api.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/web-ui/src/api.ts b/web-ui/src/api.ts index 740081a..193b0ae 100644 --- a/web-ui/src/api.ts +++ b/web-ui/src/api.ts @@ -86,11 +86,15 @@ export async function fetchBars( if (pageBars.length < 800) break } - // 按日期范围过滤(闭区间) - let bars = allBars - if (startDate) bars = bars.filter((b) => b.datetime.slice(0, 10) >= startDate) - if (endDate) bars = bars.filter((b) => b.datetime.slice(0, 10) <= endDate) - return bars + // 按日期范围过滤(闭区间) + let bars = allBars + if (startDate) bars = bars.filter((b) => b.datetime.slice(0, 10) >= startDate) + if (endDate) bars = bars.filter((b) => b.datetime.slice(0, 10) <= endDate) + // 翻页拼接后按时间正序排序:每页内部是正序,但页间是逆序 + // (page1=最新段,page2=更旧段),concat 后需排序保证整体正序, + // 否则引擎/图表只正确处理第一页的数据。 + bars.sort((a, b) => a.datetime.localeCompare(b.datetime)) + return bars } /** 把后端 bars 的单条记录归一化为统一 Bar(datetime 字段)。 */