mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
opt query pgc timeline
Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -75,7 +75,7 @@ class PgcHttp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<LoadingState<List<Result>?>> pgcTimeline({
|
static Future<LoadingState<List<TimelineResult>?>> pgcTimeline({
|
||||||
int types = 1, // 1:`番剧`<br />3:`电影`<br />4:`国创` |
|
int types = 1, // 1:`番剧`<br />3:`电影`<br />4:`国创` |
|
||||||
required int before,
|
required int before,
|
||||||
required int after,
|
required int after,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import 'package:PiliPlus/models_new/pgc/pgc_timeline/result.dart';
|
|||||||
class PgcTimeline {
|
class PgcTimeline {
|
||||||
int? code;
|
int? code;
|
||||||
String? message;
|
String? message;
|
||||||
List<Result>? result;
|
List<TimelineResult>? result;
|
||||||
|
|
||||||
PgcTimeline({this.code, this.message, this.result});
|
PgcTimeline({this.code, this.message, this.result});
|
||||||
|
|
||||||
@@ -11,7 +11,7 @@ class PgcTimeline {
|
|||||||
code: json['code'] as int?,
|
code: json['code'] as int?,
|
||||||
message: json['message'] as String?,
|
message: json['message'] as String?,
|
||||||
result: (json['result'] as List<dynamic>?)
|
result: (json['result'] as List<dynamic>?)
|
||||||
?.map((e) => Result.fromJson(e as Map<String, dynamic>))
|
?.map((e) => TimelineResult.fromJson(e as Map<String, dynamic>))
|
||||||
.toList(),
|
.toList(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import 'package:PiliPlus/models_new/pgc/pgc_timeline/episode.dart';
|
import 'package:PiliPlus/models_new/pgc/pgc_timeline/episode.dart';
|
||||||
|
|
||||||
class Result {
|
class TimelineResult {
|
||||||
String? date;
|
String? date;
|
||||||
int? dateTs;
|
int? dateTs;
|
||||||
int? dayOfWeek;
|
int? dayOfWeek;
|
||||||
List<Episode>? episodes;
|
List<Episode>? episodes;
|
||||||
int? isToday;
|
int? isToday;
|
||||||
|
|
||||||
Result({
|
TimelineResult({
|
||||||
this.date,
|
this.date,
|
||||||
this.dateTs,
|
this.dateTs,
|
||||||
this.dayOfWeek,
|
this.dayOfWeek,
|
||||||
@@ -15,7 +15,7 @@ class Result {
|
|||||||
this.isToday,
|
this.isToday,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory Result.fromJson(Map<String, dynamic> json) => Result(
|
factory TimelineResult.fromJson(Map<String, dynamic> json) => TimelineResult(
|
||||||
date: json['date'] as String?,
|
date: json['date'] as String?,
|
||||||
dateTs: json['date_ts'] as int?,
|
dateTs: json['date_ts'] as int?,
|
||||||
dayOfWeek: json['day_of_week'] as int?,
|
dayOfWeek: json['day_of_week'] as int?,
|
||||||
@@ -24,4 +24,12 @@ class Result {
|
|||||||
.toList(),
|
.toList(),
|
||||||
isToday: json['is_today'] as int?,
|
isToday: json['is_today'] as int?,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
void operator +(TimelineResult other) {
|
||||||
|
if (dateTs == other.dateTs) {
|
||||||
|
if (other.episodes case final list?) {
|
||||||
|
(episodes ??= <Episode>[]).addAll(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,12 +60,27 @@ class PgcController
|
|||||||
ScrollController? followController;
|
ScrollController? followController;
|
||||||
|
|
||||||
// timeline
|
// timeline
|
||||||
late Rx<LoadingState<List<Result>?>> timelineState =
|
late Rx<LoadingState<List<TimelineResult>?>> timelineState =
|
||||||
LoadingState<List<Result>?>.loading().obs;
|
LoadingState<List<TimelineResult>?>.loading().obs;
|
||||||
|
|
||||||
Future<void> queryPgcTimeline() async {
|
Future<void> queryPgcTimeline() async {
|
||||||
final res = await PgcHttp.pgcTimeline(types: 1, before: 6, after: 6);
|
final res = await Future.wait([
|
||||||
timelineState.value = res;
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 我的订阅
|
// 我的订阅
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ class _PgcPageState extends CommonPageState<PgcPage, PgcController>
|
|||||||
|
|
||||||
Widget _buildTimeline(
|
Widget _buildTimeline(
|
||||||
ThemeData theme,
|
ThemeData theme,
|
||||||
LoadingState<List<Result>?> loadingState,
|
LoadingState<List<TimelineResult>?> loadingState,
|
||||||
) => switch (loadingState) {
|
) => switch (loadingState) {
|
||||||
Loading() => loadingWidget,
|
Loading() => loadingWidget,
|
||||||
Success(:var response) =>
|
Success(:var response) =>
|
||||||
|
|||||||
Reference in New Issue
Block a user