refactor(watch): 观看历史改用分页契约

This commit is contained in:
Zhou Weidong authored and trae-solo-agent committed 2026-10-22 13:21:27 +08:00
1 parent 1924b8626f
commit 5b2d8445dc
2 files changed
+34 -33

No files matched your search

+8 -3
View File
@@ -40,7 +40,7 @@ class WatchApi {
return data is Map<String, dynamic> ? WatchProgress.fromJson(data) : null;
}
/// 最近观看分页(服务端已按更新时间倒序)。
/// 最近观看分页:`pageIndex`/`pageSize`,解包 `PageResult`。
Future<PageResult<WatchProgress>> recent({
int pageIndex = 1,
int pageSize = 20,
@@ -49,8 +49,13 @@ class WatchApi {
'/app/watch/recent',
query: {'pageIndex': '$pageIndex', 'pageSize': '$pageSize'},
);
// 线上可能仍返回 List;分页壳与纯数组都要能渲染。
return PageResult.parse(data, WatchProgress.fromJson);
if (data is! Map) {
return const PageResult();
}
return PageResult.fromJson(
Map<String, dynamic>.from(data),
WatchProgress.fromJson,
);
}
/// 删除某部剧的观看记录(记录页清单条用)。