perf(home): 四个根 tab 改为首次可见才构建

原先 IndexedStack 冷启动就把推荐/发现/追剧/我的四棵子树全建出来,各自还会发请求;
现在只建当前 tab,切过去再建并常驻,冷启动少三页构建和一次观看历史请求。
This commit is contained in:
Vicky authored and trae-solo-agent committed 2026-10-29 11:25:47 +08:00
1 parent 9f7301305e
commit 5649e4c3d4
2 files changed
+47 -15

No files matched your search

+2 -3
View File
@@ -36,9 +36,8 @@ void main() {
await tester.pumpWidget(_app(catalog: catalog, history: history));
await tester.pumpAndSettle();
// 首页默认停在推荐 tab:追剧页虽在 IndexedStack 里,也不该提前拉观看历史。
// 启动时只有「我的」页会拉一次,追剧页若也拉就会变成 2。
expect(history.recentCalls, 1);
// 首页默认停在推荐 tab:追剧页在启动时还没被构建,不该提前拉观看历史。
expect(history.recentCalls, 0);
await tester.tap(find.byKey(const Key('tab-follow')));
await tester.pumpAndSettle();