diff --git a/lib/http/pgc.dart b/lib/http/pgc.dart index 83f40baee..31c74d08f 100644 --- a/lib/http/pgc.dart +++ b/lib/http/pgc.dart @@ -75,7 +75,7 @@ class PgcHttp { } } - static Future?>> pgcTimeline({ + static Future?>> pgcTimeline({ int types = 1, // 1:`番剧`
3:`电影`
4:`国创` | required int before, required int after, diff --git a/lib/models_new/pgc/pgc_timeline/pgc_timeline.dart b/lib/models_new/pgc/pgc_timeline/pgc_timeline.dart index 1f8c1dcba..e6275b7e0 100644 --- a/lib/models_new/pgc/pgc_timeline/pgc_timeline.dart +++ b/lib/models_new/pgc/pgc_timeline/pgc_timeline.dart @@ -3,7 +3,7 @@ import 'package:PiliPlus/models_new/pgc/pgc_timeline/result.dart'; class PgcTimeline { int? code; String? message; - List? result; + List? result; PgcTimeline({this.code, this.message, this.result}); @@ -11,7 +11,7 @@ class PgcTimeline { code: json['code'] as int?, message: json['message'] as String?, result: (json['result'] as List?) - ?.map((e) => Result.fromJson(e as Map)) + ?.map((e) => TimelineResult.fromJson(e as Map)) .toList(), ); } diff --git a/lib/models_new/pgc/pgc_timeline/result.dart b/lib/models_new/pgc/pgc_timeline/result.dart index a897aa462..0862ca80b 100644 --- a/lib/models_new/pgc/pgc_timeline/result.dart +++ b/lib/models_new/pgc/pgc_timeline/result.dart @@ -1,13 +1,13 @@ import 'package:PiliPlus/models_new/pgc/pgc_timeline/episode.dart'; -class Result { +class TimelineResult { String? date; int? dateTs; int? dayOfWeek; List? episodes; int? isToday; - Result({ + TimelineResult({ this.date, this.dateTs, this.dayOfWeek, @@ -15,7 +15,7 @@ class Result { this.isToday, }); - factory Result.fromJson(Map json) => Result( + factory TimelineResult.fromJson(Map json) => TimelineResult( date: json['date'] as String?, dateTs: json['date_ts'] as int?, dayOfWeek: json['day_of_week'] as int?, @@ -24,4 +24,12 @@ class Result { .toList(), isToday: json['is_today'] as int?, ); + + void operator +(TimelineResult other) { + if (dateTs == other.dateTs) { + if (other.episodes case final list?) { + (episodes ??= []).addAll(list); + } + } + } } diff --git a/lib/pages/pgc/controller.dart b/lib/pages/pgc/controller.dart index 050bc61b3..69749bf00 100644 --- a/lib/pages/pgc/controller.dart +++ b/lib/pages/pgc/controller.dart @@ -60,12 +60,27 @@ class PgcController ScrollController? followController; // timeline - late Rx?>> timelineState = - LoadingState?>.loading().obs; + late Rx?>> timelineState = + LoadingState?>.loading().obs; Future queryPgcTimeline() async { - final res = await PgcHttp.pgcTimeline(types: 1, before: 6, after: 6); - timelineState.value = res; + final res = await Future.wait([ + PgcHttp.pgcTimeline(types: 1, before: 6, after: 6), + PgcHttp.pgcTimeline(types: 4, before: 6, after: 6), + ]); + var list1 = res.first.dataOrNull; + var list2 = res[1].dataOrNull; + if (list1 != null && + list2 != null && + list1.isNotEmpty && + list2.isNotEmpty) { + for (var i = 0; i < list1.length; i++) { + list1[i] + list2[i]; + } + } else { + list1 ??= list2; + } + timelineState.value = Success(list1); } // 我的订阅 diff --git a/lib/pages/pgc/view.dart b/lib/pages/pgc/view.dart index 5738e8d41..0bb066e8b 100644 --- a/lib/pages/pgc/view.dart +++ b/lib/pages/pgc/view.dart @@ -77,7 +77,7 @@ class _PgcPageState extends CommonPageState Widget _buildTimeline( ThemeData theme, - LoadingState?> loadingState, + LoadingState?> loadingState, ) => switch (loadingState) { Loading() => loadingWidget, Success(:var response) =>