mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-20 17:16:29 +08:00
@@ -3,6 +3,7 @@ import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/constants.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/http/loading_state.dart';
|
||||
import 'package:PiliPlus/http/reply.dart';
|
||||
import 'package:PiliPlus/models/common/dynamic/dynamics_type.dart';
|
||||
import 'package:PiliPlus/models/common/reply/reply_option_type.dart';
|
||||
import 'package:PiliPlus/models/dynamics/result.dart';
|
||||
@@ -19,7 +20,6 @@ import 'package:PiliPlus/models_new/dynamic/dyn_topic_feed/topic_card_list.dart'
|
||||
import 'package:PiliPlus/models_new/dynamic/dyn_topic_top/top_details.dart';
|
||||
import 'package:PiliPlus/models_new/dynamic/dyn_topic_top/topic_item.dart';
|
||||
import 'package:PiliPlus/utils/accounts.dart';
|
||||
import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:PiliPlus/utils/utils.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
@@ -232,9 +232,7 @@ class DynamicsHttp {
|
||||
'{"platform":"web","device":"pc","spmid":"333.1330"}',
|
||||
if (!clearCookie && Accounts.main.isLogin) 'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: clearCookie
|
||||
? Options(extra: {'account': AnonymousAccount(), 'checkReply': true})
|
||||
: null,
|
||||
options: clearCookie ? ReplyHttp.options : null,
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
try {
|
||||
|
||||
@@ -115,13 +115,7 @@ class Request {
|
||||
receiveTimeout: const Duration(milliseconds: 10000),
|
||||
//Http请求头.
|
||||
headers: {
|
||||
'connection': 'keep-alive',
|
||||
'accept-encoding': 'br,gzip',
|
||||
'user-agent': 'Dart/3.6 (dart:io)', // Http2Adapter不会自动添加标头
|
||||
'referer': HttpString.baseUrl,
|
||||
'env': 'prod',
|
||||
'app-key': 'android64',
|
||||
'x-bili-aurora-zone': 'sh001',
|
||||
},
|
||||
responseDecoder: responseDecoder, // Http2Adapter没有自动解压
|
||||
persistentConnection: true,
|
||||
@@ -205,14 +199,7 @@ class Request {
|
||||
Map<String, dynamic>? queryParameters,
|
||||
Options? options,
|
||||
CancelToken? cancelToken,
|
||||
String? uaType,
|
||||
}) async {
|
||||
if (uaType != null) {
|
||||
options ??= Options();
|
||||
options.headers ??= <String, dynamic>{};
|
||||
options.headers!['user-agent'] = headerUa(type: uaType);
|
||||
}
|
||||
|
||||
try {
|
||||
return await dio.get<T>(
|
||||
url,
|
||||
|
||||
@@ -12,8 +12,9 @@ import 'package:PiliPlus/utils/accounts/account.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class ReplyHttp {
|
||||
static final Options _options = Options(
|
||||
extra: {'account': AnonymousAccount(), 'checkReply': true},
|
||||
static final Options options = Options(
|
||||
headers: {...Constants.baseHeaders, 'cookie': ''},
|
||||
extra: {'account': NoAccount()},
|
||||
);
|
||||
|
||||
static Future<LoadingState> replyList({
|
||||
@@ -36,7 +37,7 @@ class ReplyHttp {
|
||||
'{"offset":"${nextOffset.replaceAll('"', '\\"')}"}',
|
||||
'mode': sort + 2, //2:按时间排序;3:按热度排序
|
||||
},
|
||||
options: !isLogin ? _options : null,
|
||||
options: !isLogin ? options : null,
|
||||
)
|
||||
: await Request().get(
|
||||
Api.replyList,
|
||||
@@ -47,7 +48,7 @@ class ReplyHttp {
|
||||
'pn': page,
|
||||
'ps': 20,
|
||||
},
|
||||
options: !isLogin ? _options : null,
|
||||
options: !isLogin ? options : null,
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
ReplyData replyData = ReplyData.fromJson(res.data['data']);
|
||||
@@ -155,7 +156,7 @@ class ReplyHttp {
|
||||
'sort': 1,
|
||||
if (isLogin) 'csrf': Accounts.main.csrf,
|
||||
},
|
||||
options: !isLogin ? _options : null,
|
||||
options: !isLogin ? options : null,
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
ReplyReplyData replyData = ReplyReplyData.fromJson(res.data['data']);
|
||||
|
||||
Reference in New Issue
Block a user