mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
@@ -129,7 +129,7 @@ class Api {
|
||||
|
||||
// 评论列表
|
||||
// https://api.bilibili.com/x/v2/reply/main?csrf=6e22efc1a47225ea25f901f922b5cfdd&mode=3&oid=254175381&pagination_str=%7B%22offset%22:%22%22%7D&plat=1&seek_rpid=0&type=11
|
||||
static const String replyList = '/x/v2/reply/main';
|
||||
static const String replyList = '/x/v2/reply';
|
||||
|
||||
// 楼中楼
|
||||
static const String replyReplyList = '/x/v2/reply/reply';
|
||||
|
||||
@@ -13,9 +13,9 @@ import 'init.dart';
|
||||
class ReplyHttp {
|
||||
static Future<LoadingState> replyList({
|
||||
required int oid,
|
||||
required String nextOffset,
|
||||
required int type,
|
||||
int sort = 1,
|
||||
required int page,
|
||||
}) async {
|
||||
Options? options = GStorage.userInfo.get('userInfoCache') == null
|
||||
? Options(
|
||||
@@ -26,8 +26,9 @@ class ReplyHttp {
|
||||
data: {
|
||||
'oid': oid,
|
||||
'type': type,
|
||||
'pagination_str': '{"offset":"${nextOffset.replaceAll('"', '\\"')}"}',
|
||||
'mode': sort + 2, //2:按时间排序;3:按热度排序
|
||||
'sort': sort,
|
||||
'pn': page,
|
||||
'ps': 20,
|
||||
},
|
||||
options: options,
|
||||
);
|
||||
|
||||
@@ -6,31 +6,29 @@ import 'upper.dart';
|
||||
|
||||
class ReplyData {
|
||||
ReplyData({
|
||||
this.cursor,
|
||||
this.page,
|
||||
this.config,
|
||||
this.replies,
|
||||
this.topReplies,
|
||||
this.upper,
|
||||
});
|
||||
|
||||
ReplyCursor? cursor;
|
||||
ReplyPage? page;
|
||||
ReplyConfig? config;
|
||||
late List<ReplyItemModel>? replies;
|
||||
late List<ReplyItemModel>? topReplies;
|
||||
ReplyUpper? upper;
|
||||
|
||||
ReplyData.fromJson(Map<String, dynamic> json) {
|
||||
cursor = ReplyCursor.fromJson(json['cursor']);
|
||||
page = ReplyPage.fromJson(json['page']);
|
||||
config = ReplyConfig.fromJson(json['config']);
|
||||
replies = json['replies'] != null
|
||||
? List<ReplyItemModel>.from(json['replies']
|
||||
.map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'])))
|
||||
? List<ReplyItemModel>.from(json['replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'])))
|
||||
: <ReplyItemModel>[];
|
||||
topReplies = json['top_replies'] != null
|
||||
? List<ReplyItemModel>.from(json['top_replies']
|
||||
.map<ReplyItemModel>((item) => ReplyItemModel.fromJson(
|
||||
item, json['upper']['mid'],
|
||||
? List<ReplyItemModel>.from(json['top_replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'],
|
||||
isTopStatus: true)))
|
||||
: <ReplyItemModel>[];
|
||||
upper = ReplyUpper.fromJson(json['upper']);
|
||||
@@ -58,15 +56,13 @@ class ReplyReplyData {
|
||||
page = ReplyPage.fromJson(json['page']);
|
||||
config = ReplyConfig.fromJson(json['config']);
|
||||
replies = json['replies'] != null
|
||||
? List<ReplyItemModel>.from(json['replies']
|
||||
.map<ReplyItemModel>(
|
||||
? List<ReplyItemModel>.from(json['replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'])))
|
||||
: <ReplyItemModel>[];
|
||||
topReplies = json['top_replies'] != null
|
||||
? List<ReplyItemModel>.from(json['top_replies']
|
||||
.map<ReplyItemModel>((item) => ReplyItemModel.fromJson(
|
||||
item, json['upper']['mid'],
|
||||
isTopStatus: true)))
|
||||
? List<ReplyItemModel>.from(json['top_replies'].map<ReplyItemModel>(
|
||||
(item) => ReplyItemModel.fromJson(item, json['upper']['mid'],
|
||||
isTopStatus: true)))
|
||||
: <ReplyItemModel>[];
|
||||
upper = ReplyUpper.fromJson(json['upper']);
|
||||
root = ReplyItemModel.fromJson(json['root'], json['upper']['mid']);
|
||||
|
||||
@@ -41,7 +41,6 @@ abstract class ReplyController extends CommonController {
|
||||
|
||||
@override
|
||||
Future onRefresh() {
|
||||
nextOffset = '';
|
||||
noMore.value = '';
|
||||
return super.onRefresh();
|
||||
}
|
||||
@@ -55,7 +54,6 @@ abstract class ReplyController extends CommonController {
|
||||
@override
|
||||
bool customHandleResponse(Success response) {
|
||||
List<ReplyItemModel> replies = response.response.replies;
|
||||
nextOffset = response.response.cursor.paginationReply.nextOffset ?? "";
|
||||
if (replies.isNotEmpty) {
|
||||
noMore.value = '加载中...';
|
||||
|
||||
@@ -78,7 +76,7 @@ abstract class ReplyController extends CommonController {
|
||||
}
|
||||
}
|
||||
replies.insertAll(0, response.response.topReplies);
|
||||
count.value = response.response.cursor.allCount ?? 0;
|
||||
count.value = response.response.page.count ?? 0;
|
||||
} else {
|
||||
replies.insertAll(
|
||||
0,
|
||||
|
||||
@@ -35,8 +35,8 @@ class DynamicDetailController extends ReplyController {
|
||||
@override
|
||||
Future<LoadingState> customGetData() => ReplyHttp.replyList(
|
||||
oid: oid!,
|
||||
nextOffset: nextOffset,
|
||||
type: type!,
|
||||
sort: sortType.index,
|
||||
page: currentPage,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ class HtmlRenderController extends ReplyController {
|
||||
@override
|
||||
Future<LoadingState> customGetData() => ReplyHttp.replyList(
|
||||
oid: oid.value,
|
||||
nextOffset: nextOffset,
|
||||
type: type,
|
||||
sort: sortType.index,
|
||||
page: currentPage,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ class VideoReplyController extends ReplyController {
|
||||
@override
|
||||
Future<LoadingState> customGetData() => ReplyHttp.replyList(
|
||||
oid: aid!,
|
||||
nextOffset: nextOffset,
|
||||
type: ReplyType.video.index,
|
||||
sort: sortType.index,
|
||||
page: currentPage,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user