fix: 未登录状态下评论区条数受限(需移除cookie)

https://github.com/orz12/PiliPalaX/pull/214
This commit is contained in:
orz12
2024-09-02 08:18:37 +08:00
committed by bggRGjQaUbCoE
parent 33268278d0
commit 4f611663cb

View File

@@ -1,5 +1,7 @@
import 'dart:io';
import 'package:PiliPalaX/http/loading_state.dart'; import 'package:PiliPalaX/http/loading_state.dart';
import 'package:PiliPalaX/utils/extension.dart'; import 'package:PiliPalaX/utils/storage.dart';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import '../models/video/reply/data.dart'; import '../models/video/reply/data.dart';
@@ -9,29 +11,31 @@ import 'constants.dart';
import 'init.dart'; import 'init.dart';
class ReplyHttp { class ReplyHttp {
static final _dio = Dio();
static Future<LoadingState> replyList({ static Future<LoadingState> replyList({
required int oid, required int oid,
required String nextOffset, required String nextOffset,
required int type, required int type,
int sort = 1, int sort = 1,
}) async { }) async {
try { Options? options = GStorage.userInfo.get('userInfoCache') == null
var res = await _dio ? Options(
.get('${HttpString.apiBaseUrl}${Api.replyList}', queryParameters: { headers: {HttpHeaders.cookieHeader: "buvid3= ; b_nut= ; sid= "})
: null;
var res = await Request().get(
'${HttpString.apiBaseUrl}${Api.replyList}',
data: {
'oid': oid, 'oid': oid,
'type': type, 'type': type,
'pagination_str': '{"offset":"${nextOffset.replaceAll('"', '\\"')}"}', 'pagination_str': '{"offset":"${nextOffset.replaceAll('"', '\\"')}"}',
'mode': sort + 2, //2:按时间排序3按热度排序 'mode': sort + 2, //2:按时间排序3按热度排序
}); },
options: options,
);
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return LoadingState.success(ReplyData.fromJson(res.data['data'])); return LoadingState.success(ReplyData.fromJson(res.data['data']));
} else { } else {
return LoadingState.error(res.data['message']); return LoadingState.error(res.data['message']);
} }
} catch (e) {
return LoadingState.error(e.toString());
}
} }
static Future<LoadingState> replyReplyList({ static Future<LoadingState> replyReplyList({
@@ -41,24 +45,27 @@ class ReplyHttp {
required int type, required int type,
int sort = 1, int sort = 1,
}) async { }) async {
try { Options? options = GStorage.userInfo.get('userInfoCache') == null
var res = await _dio.get('${HttpString.apiBaseUrl}${Api.replyReplyList}', ? Options(
queryParameters: { headers: {HttpHeaders.cookieHeader: "buvid3= ; b_nut= ; sid= "})
: null;
var res = await Request().get(
'${HttpString.apiBaseUrl}${Api.replyReplyList}',
data: {
'oid': oid, 'oid': oid,
'root': root, 'root': root,
'pn': pageNum, 'pn': pageNum,
'type': type, 'type': type,
'sort': 1, 'sort': 1,
'csrf': await Request.getCsrf(), 'csrf': await Request.getCsrf(),
}); },
options: options,
);
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return LoadingState.success(ReplyReplyData.fromJson(res.data['data'])); return LoadingState.success(ReplyReplyData.fromJson(res.data['data']));
} else { } else {
return LoadingState.error(res.data['message']); return LoadingState.error(res.data['message']);
} }
} catch (e) {
return LoadingState.error(e.toString());
}
} }
// 评论点赞 // 评论点赞