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