From e9b5959e9c3468fe65f47f15851da3eac9bddc21 Mon Sep 17 00:00:00 2001 From: dom Date: Sat, 9 May 2026 21:46:11 +0800 Subject: [PATCH] tweaks Signed-off-by: dom --- lib/common/skeleton/dynamic_card.dart | 2 +- lib/grpc/grpc_req.dart | 2 +- lib/http/black.dart | 2 +- lib/http/danmaku.dart | 10 +- lib/http/danmaku_block.dart | 6 +- lib/http/dynamics.dart | 60 +++--- lib/http/fan.dart | 2 +- lib/http/fav.dart | 70 +++---- lib/http/follow.dart | 4 +- lib/http/init.dart | 20 +- lib/http/live.dart | 50 ++--- lib/http/login.dart | 30 +-- lib/http/match.dart | 2 +- lib/http/member.dart | 62 +++--- lib/http/msg.dart | 50 ++--- lib/http/music.dart | 6 +- lib/http/pgc.dart | 22 +- lib/http/reply.dart | 20 +- lib/http/search.dart | 20 +- lib/http/sponsor_block.dart | 16 +- lib/http/user.dart | 64 +++--- lib/http/validate.dart | 4 +- lib/http/video.dart | 76 +++---- lib/main.dart | 2 +- lib/pages/audio/controller.dart | 6 +- lib/pages/blacklist/view.dart | 2 +- lib/pages/common/common_intro_controller.dart | 2 +- lib/pages/dynamics_tab/view.dart | 2 +- lib/pages/dynamics_topic/view.dart | 2 +- lib/pages/login/controller.dart | 2 +- .../login/geetest/geetest_webview_dialog.dart | 2 +- lib/pages/member_dynamics/view.dart | 2 +- lib/pages/member_favorite/controller.dart | 4 +- lib/pages/member_profile/view.dart | 190 +++++++++--------- lib/pages/member_search/child/view.dart | 2 +- lib/pages/setting/models/style_settings.dart | 2 +- lib/pages/video/controller.dart | 2 +- .../video/introduction/pgc/controller.dart | 4 +- .../video/introduction/ugc/controller.dart | 6 +- lib/pages/video/pay_coins/view.dart | 2 +- lib/utils/global_data.dart | 21 +- lib/utils/image_utils.dart | 10 +- lib/utils/page_utils.dart | 4 +- lib/utils/storage_pref.dart | 4 +- lib/utils/waterfall.dart | 4 +- lib/utils/wbi_sign.dart | 2 +- 46 files changed, 431 insertions(+), 448 deletions(-) diff --git a/lib/common/skeleton/dynamic_card.dart b/lib/common/skeleton/dynamic_card.dart index dad22498d..98eff05ad 100644 --- a/lib/common/skeleton/dynamic_card.dart +++ b/lib/common/skeleton/dynamic_card.dart @@ -90,7 +90,7 @@ class DynamicCardSkeleton extends StatelessWidget { height: 13, margin: const EdgeInsets.only(bottom: 7), ), - if (GlobalData().dynamicsWaterfallFlow) const Spacer(), + if (GlobalData.dynamicsWaterfallFlow) const Spacer(), Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: const ['转发', '评论', '点赞'] diff --git a/lib/grpc/grpc_req.dart b/lib/grpc/grpc_req.dart index e221f0a1d..4cd3d3b2f 100644 --- a/lib/grpc/grpc_req.dart +++ b/lib/grpc/grpc_req.dart @@ -58,7 +58,7 @@ abstract final class GrpcReq { T Function(Uint8List) grpcParser, { bool isolate = false, }) async { - final response = await Request().post( + final response = await Request.post( HttpString.appBaseUrl + url, data: compressProtobuf(request.writeToBuffer()), options: options, diff --git a/lib/http/black.dart b/lib/http/black.dart index bc9713484..ef8ac1360 100644 --- a/lib/http/black.dart +++ b/lib/http/black.dart @@ -9,7 +9,7 @@ abstract final class BlackHttp { required int pn, int ps = 50, }) async { - final res = await Request().get( + final res = await Request.get( Api.blackLst, queryParameters: { 'pn': pn, diff --git a/lib/http/danmaku.dart b/lib/http/danmaku.dart index 2d5b9efbf..a97855b21 100644 --- a/lib/http/danmaku.dart +++ b/lib/http/danmaku.dart @@ -47,7 +47,7 @@ abstract final class DanmakuHttp { // 'access_key': access_key, }; - final res = await Request().post( + final res = await Request.post( Api.shootDanmaku, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -77,7 +77,7 @@ abstract final class DanmakuHttp { 'statistics': '{"appId":100,"platform":5,"abtest":"","version":""}', 'csrf': Accounts.main.csrf, }; - final res = await Request().post( + final res = await Request.post( Api.danmakuLike, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -110,7 +110,7 @@ abstract final class DanmakuHttp { 'statistics': '{"appId":100,"platform":5,"abtest":"","version":""}', 'csrf': Accounts.main.csrf, }; - final res = await Request().post( + final res = await Request.post( Api.danmakuReport, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -144,7 +144,7 @@ abstract final class DanmakuHttp { 'type': 1, 'csrf': Accounts.main.csrf, }; - final res = await Request().post( + final res = await Request.post( Api.danmakuRecall, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -172,7 +172,7 @@ abstract final class DanmakuHttp { 'type': 1, 'csrf': Accounts.main.csrf, }; - final res = await Request().post( + final res = await Request.post( Api.danmakuRecall, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), diff --git a/lib/http/danmaku_block.dart b/lib/http/danmaku_block.dart index c6bf1c68e..48af2b5ae 100644 --- a/lib/http/danmaku_block.dart +++ b/lib/http/danmaku_block.dart @@ -7,7 +7,7 @@ import 'package:dio/dio.dart'; abstract final class DanmakuFilterHttp { static Future> danmakuFilter() async { - final res = await Request().get(Api.danmakuFilter); + final res = await Request.get(Api.danmakuFilter); if (res.data['code'] == 0) { return Success(DanmakuBlockDataModel.fromJson(res.data['data'])); } else { @@ -16,7 +16,7 @@ abstract final class DanmakuFilterHttp { } static Future> danmakuFilterDel({required int ids}) async { - final res = await Request().post( + final res = await Request.post( Api.danmakuFilterDel, data: { 'ids': ids, @@ -35,7 +35,7 @@ abstract final class DanmakuFilterHttp { required String filter, required int type, }) async { - final res = await Request().post( + final res = await Request.post( Api.danmakuFilterAdd, data: { 'type': type, diff --git a/lib/http/dynamics.dart b/lib/http/dynamics.dart index 7ef924a8d..a8cb6fd49 100644 --- a/lib/http/dynamics.dart +++ b/lib/http/dynamics.dart @@ -47,7 +47,7 @@ abstract final class DynamicsHttp { 'offset': offset, 'features': Constants.dynFeatures, }; - final res = await Request().get(Api.followDynamic, queryParameters: data); + final res = await Request.get(Api.followDynamic, queryParameters: data); final code = res.data['code']; if (code == 0) { try { @@ -74,7 +74,7 @@ abstract final class DynamicsHttp { } static Future> followUp() async { - final res = await Request().get( + final res = await Request.get( Api.followUp, queryParameters: { 'up_list_more': 1, @@ -89,7 +89,7 @@ abstract final class DynamicsHttp { } static Future> dynUpList(String? offset) async { - final res = await Request().get( + final res = await Request.get( Api.dynUplist, queryParameters: { 'offset': offset, @@ -109,7 +109,7 @@ abstract final class DynamicsHttp { // required String? dynamicId, // required int? up, // }) async { - // final res = await Request().post( + // final res = await Request.post( // Api.likeDynamic, // queryParameters: { // 'dynamic_id': dynamicId, @@ -132,7 +132,7 @@ abstract final class DynamicsHttp { required String? dynamicId, required int? up, }) async { - final res = await Request().post( + final res = await Request.post( Api.thumbDynamic, queryParameters: { 'csrf': Accounts.main.csrf, @@ -170,7 +170,7 @@ abstract final class DynamicsHttp { String? title, Map? attachCard, }) async { - final res = await Request().post( + final res = await Request.post( Api.createDynamic, queryParameters: { 'platform': 'web', @@ -249,7 +249,7 @@ abstract final class DynamicsHttp { dynamic type, bool clearCookie = false, }) async { - final res = await Request().get( + final res = await Request.get( Api.dynamicDetail, queryParameters: { 'timezone_offset': -480, @@ -279,7 +279,7 @@ abstract final class DynamicsHttp { static Future> setTop({ required Object dynamicId, }) async { - final res = await Request().post( + final res = await Request.post( Api.setTopDyn, queryParameters: { 'csrf': Accounts.main.csrf, @@ -298,7 +298,7 @@ abstract final class DynamicsHttp { static Future> rmTop({ required Object dynamicId, }) async { - final res = await Request().post( + final res = await Request.post( Api.rmTopDyn, queryParameters: { 'csrf': Accounts.main.csrf, @@ -317,7 +317,7 @@ abstract final class DynamicsHttp { static Future> articleInfo({ required Object cvId, }) async { - final res = await Request().get( + final res = await Request.get( Api.articleInfo, queryParameters: await WbiSign.makSign({ 'id': cvId, @@ -336,7 +336,7 @@ abstract final class DynamicsHttp { static Future> articleView({ required dynamic cvId, }) async { - final res = await Request().get( + final res = await Request.get( Api.articleView, queryParameters: await WbiSign.makSign({ 'id': cvId, @@ -354,7 +354,7 @@ abstract final class DynamicsHttp { static Future> opusDetail({ required dynamic opusId, }) async { - final res = await Request().get( + final res = await Request.get( Api.opusDetail, queryParameters: await WbiSign.makSign({ 'timezone_offset': '-480', @@ -370,7 +370,7 @@ abstract final class DynamicsHttp { } static Future> voteInfo(dynamic voteId) async { - final res = await Request().get( + final res = await Request.get( Api.voteInfo, queryParameters: {'vote_id': voteId}, ); @@ -398,7 +398,7 @@ abstract final class DynamicsHttp { 'csrf_token': csrf, 'csrf': csrf, }; - final res = await Request().post( + final res = await Request.post( Api.doVote, queryParameters: {'csrf': csrf}, data: data, @@ -414,7 +414,7 @@ abstract final class DynamicsHttp { static Future> topicTop({ required Object topicId, }) async { - final res = await Request().get( + final res = await Request.get( Api.topicTop, queryParameters: { 'topic_id': topicId, @@ -436,7 +436,7 @@ abstract final class DynamicsHttp { required String offset, required int sortBy, }) async { - final res = await Request().get( + final res = await Request.get( Api.topicFeed, queryParameters: { 'topic_id': topicId, @@ -460,7 +460,7 @@ abstract final class DynamicsHttp { static Future> articleList({ required Object id, }) async { - final res = await Request().get( + final res = await Request.get( Api.articleList, queryParameters: { 'id': id, @@ -480,7 +480,7 @@ abstract final class DynamicsHttp { required Object dynamicIdStr, required Object? reserveTotal, }) async { - final res = await Request().post( + final res = await Request.post( Api.dynReserve, queryParameters: { 'csrf': Accounts.main.csrf, @@ -502,7 +502,7 @@ abstract final class DynamicsHttp { static Future?>> dynTopicRcmd({ int ps = 25, }) async { - final res = await Request().get( + final res = await Request.get( Api.dynTopicRcmd, queryParameters: { 'source': 'Web', @@ -522,7 +522,7 @@ abstract final class DynamicsHttp { } static Future?>> dynPic(dynamic id) async { - final res = await Request().get( + final res = await Request.get( Api.dynPic, queryParameters: { 'id': id, @@ -543,7 +543,7 @@ abstract final class DynamicsHttp { static Future?>> dynMention({ String? keyword, }) async { - final res = await Request().get( + final res = await Request.get( Api.dynMention, queryParameters: { if (keyword != null && keyword.isNotEmpty) 'keyword': keyword, @@ -560,7 +560,7 @@ abstract final class DynamicsHttp { } static Future> createVote(VoteInfo voteInfo) async { - final res = await Request().post( + final res = await Request.post( Api.createVote, queryParameters: {'csrf': Accounts.main.csrf}, data: {'vote_info': voteInfo.toJson()}, @@ -573,7 +573,7 @@ abstract final class DynamicsHttp { } static Future> updateVote(VoteInfo voteInfo) async { - final res = await Request().post( + final res = await Request.post( Api.updateVote, queryParameters: {'csrf': Accounts.main.csrf}, data: {'vote_info': voteInfo.toJson()}, @@ -590,7 +590,7 @@ abstract final class DynamicsHttp { required String title, required int livePlanStartTime, }) async { - final res = await Request().post( + final res = await Request.post( Api.createReserve, data: { 'type': 2, @@ -615,7 +615,7 @@ abstract final class DynamicsHttp { required int livePlanStartTime, required int sid, }) async { - final res = await Request().post( + final res = await Request.post( Api.updateReserve, data: { 'type': 2, @@ -638,7 +638,7 @@ abstract final class DynamicsHttp { static Future> reserveInfo({ required dynamic sid, }) async { - final res = await Request().get( + final res = await Request.get( Api.reserveInfo, queryParameters: { 'from': 1, @@ -656,7 +656,7 @@ abstract final class DynamicsHttp { static Future?>> followeeVotes({ required dynamic voteId, }) async { - final res = await Request().get( + final res = await Request.get( Api.followeeVotes, queryParameters: { 'vote_id': voteId, @@ -678,7 +678,7 @@ abstract final class DynamicsHttp { int? dynType, required String action, }) async { - final res = await Request().post( + final res = await Request.post( Api.dynPrivatePubSetting, queryParameters: { 'platform': 'web', @@ -714,7 +714,7 @@ abstract final class DynamicsHttp { }) async { final uploadId = "${Accounts.main.mid}_${DateTime.now().millisecondsSinceEpoch ~/ 1000}_${Utils.random.nextInt(9000) + 1000}"; - final res = await Request().post( + final res = await Request.post( Api.editDyn, queryParameters: await WbiSign.makSign({ 'platform': 'web', @@ -785,7 +785,7 @@ abstract final class DynamicsHttp { int? sortType, required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.bubble, queryParameters: { 'tribee_id': tribeId, diff --git a/lib/http/fan.dart b/lib/http/fan.dart index 947eabf45..4e7352f81 100644 --- a/lib/http/fan.dart +++ b/lib/http/fan.dart @@ -11,7 +11,7 @@ abstract final class FanHttp { int ps = 20, String? orderType, }) async { - final res = await Request().get( + final res = await Request.get( Api.fans, queryParameters: { 'vmid': vmid, diff --git a/lib/http/fav.dart b/lib/http/fav.dart index 1d806a4d2..e57232cd8 100644 --- a/lib/http/fav.dart +++ b/lib/http/fav.dart @@ -19,7 +19,7 @@ import 'package:dio/dio.dart'; abstract final class FavHttp { static Future> favFavFolder(Object mediaId) async { - final res = await Request().post( + final res = await Request.post( Api.favFavFolder, data: { 'media_id': mediaId, @@ -35,7 +35,7 @@ abstract final class FavHttp { } static Future> unfavFavFolder(Object mediaId) async { - final res = await Request().post( + final res = await Request.post( Api.unfavFavFolder, data: { 'media_id': mediaId, @@ -58,7 +58,7 @@ abstract final class FavHttp { FavOrderType order = FavOrderType.mtime, int type = 0, }) async { - final res = await Request().get( + final res = await Request.get( Api.favResourceList, queryParameters: { 'media_id': mediaId, @@ -84,7 +84,7 @@ abstract final class FavHttp { required int type, }) async { final res = type == 11 - ? await Request().post( + ? await Request.post( Api.unfavFolder, data: { 'media_id': id, @@ -92,7 +92,7 @@ abstract final class FavHttp { }, options: Options(contentType: Headers.formUrlEncodedContentType), ) - : await Request().post( + : await Request.post( Api.unfavSeason, data: { 'platform': 'web', @@ -113,7 +113,7 @@ abstract final class FavHttp { required int pn, required int ps, }) async { - final res = await Request().get( + final res = await Request.get( Api.favSeasonList, queryParameters: { 'season_id': id, @@ -132,7 +132,7 @@ abstract final class FavHttp { required int mid, required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.favPugv, queryParameters: { 'mid': mid, @@ -149,7 +149,7 @@ abstract final class FavHttp { } static Future> addFavPugv(Object seasonId) async { - final res = await Request().post( + final res = await Request.post( Api.addFavPugv, data: { 'season_id': seasonId, @@ -165,7 +165,7 @@ abstract final class FavHttp { } static Future> delFavPugv(Object seasonId) async { - final res = await Request().post( + final res = await Request.post( Api.delFavPugv, data: { 'season_id': seasonId, @@ -183,7 +183,7 @@ abstract final class FavHttp { static Future> favTopic({ required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.favTopicList, queryParameters: { 'page_size': 24, @@ -199,7 +199,7 @@ abstract final class FavHttp { } static Future> addFavTopic(Object topicId) async { - final res = await Request().post( + final res = await Request.post( Api.addFavTopic, data: { 'topic_id': topicId, @@ -215,7 +215,7 @@ abstract final class FavHttp { } static Future> delFavTopic(Object topicId) async { - final res = await Request().post( + final res = await Request.post( Api.delFavTopic, data: { 'topic_id': topicId, @@ -234,7 +234,7 @@ abstract final class FavHttp { Object topicId, bool isLike, ) async { - final res = await Request().post( + final res = await Request.post( Api.likeTopic, data: { 'action': isLike ? 'cancel_like' : 'like', @@ -255,7 +255,7 @@ abstract final class FavHttp { static Future> favArticle({ required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.favArticle, queryParameters: { 'page_size': 20, @@ -272,7 +272,7 @@ abstract final class FavHttp { static Future> addFavArticle({ required Object id, }) async { - final res = await Request().post( + final res = await Request.post( Api.addFavArticle, data: { 'id': id, @@ -292,7 +292,7 @@ abstract final class FavHttp { static Future> delFavArticle({ required Object id, }) async { - final res = await Request().post( + final res = await Request.post( Api.delFavArticle, data: { 'id': id, @@ -312,7 +312,7 @@ abstract final class FavHttp { static Future?>> userNoteList({ required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.userNoteList, queryParameters: { 'pn': page, @@ -333,7 +333,7 @@ abstract final class FavHttp { static Future?>> noteList({ required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.noteList, queryParameters: { 'pn': page, @@ -355,7 +355,7 @@ abstract final class FavHttp { required bool isPublish, required String noteIds, }) async { - final res = await Request().post( + final res = await Request.post( isPublish ? Api.delPublishNote : Api.delNote, data: { isPublish ? 'cvids' : 'note_ids': noteIds, @@ -378,7 +378,7 @@ abstract final class FavHttp { int? followStatus, Object? mid, }) async { - final res = await Request().get( + final res = await Request.get( Api.favPgc, queryParameters: { 'vmid': mid ?? Accounts.main.mid, @@ -400,7 +400,7 @@ abstract final class FavHttp { required int ps, required dynamic mid, }) async { - final res = await Request().get( + final res = await Request.get( Api.userFavFolder, queryParameters: { 'pn': pn, @@ -423,7 +423,7 @@ abstract final class FavHttp { 'csrf': Accounts.main.csrf, }; AppSign.appSign(data); - final res = await Request().post( + final res = await Request.post( Api.sortFavFolder, data: data, options: Options( @@ -447,7 +447,7 @@ abstract final class FavHttp { 'csrf': Accounts.main.csrf, }; AppSign.appSign(data); - final res = await Request().post( + final res = await Request.post( Api.sortFav, data: data, options: Options( @@ -464,7 +464,7 @@ abstract final class FavHttp { static Future> cleanFav({ required Object mediaId, }) async { - final res = await Request().post( + final res = await Request.post( Api.cleanFav, data: { 'media_id': mediaId, @@ -485,7 +485,7 @@ abstract final class FavHttp { static Future> deleteFolder({ required String mediaIds, }) async { - final res = await Request().post( + final res = await Request.post( Api.deleteFolder, data: { 'media_ids': mediaIds, @@ -511,7 +511,7 @@ abstract final class FavHttp { required String cover, required String intro, }) async { - final res = await Request().post( + final res = await Request.post( isAdd ? Api.addFolder : Api.editFolder, data: { 'title': title, @@ -535,7 +535,7 @@ abstract final class FavHttp { static Future> favFolderInfo({ required Object mediaId, }) async { - final res = await Request().get( + final res = await Request.get( Api.favFolderInfo, queryParameters: { 'media_id': mediaId, @@ -552,7 +552,7 @@ abstract final class FavHttp { required bool isFav, required dynamic seasonId, }) async { - final res = await Request().post( + final res = await Request.post( isFav ? Api.unfavSeason : Api.favSeason, data: { 'platform': 'web', @@ -584,7 +584,7 @@ abstract final class FavHttp { 'statistics': Constants.statisticsApp, 'up_mid': mid, }; - final res = await Request().get( + final res = await Request.get( Api.spaceFav, queryParameters: params, options: Options( @@ -609,7 +609,7 @@ abstract final class FavHttp { required Object opusId, required Object action, }) async { - final res = await Request().post( + final res = await Request.post( Api.communityAction, queryParameters: { 'csrf': Accounts.main.csrf, @@ -635,7 +635,7 @@ abstract final class FavHttp { String? addIds, String? delIds, }) async { - final res = await Request().post( + final res = await Request.post( Api.favVideo, data: { 'resources': resources, @@ -657,7 +657,7 @@ abstract final class FavHttp { required Object rid, required Object type, }) async { - final res = await Request().post( + final res = await Request.post( Api.unfavAll, data: { 'rid': rid, @@ -681,7 +681,7 @@ abstract final class FavHttp { dynamic mid, required String resources, }) async { - final res = await Request().post( + final res = await Request.post( isFav ? isCopy ? Api.copyFav @@ -707,7 +707,7 @@ abstract final class FavHttp { } static Future> allFavFolders(Object mid) async { - final res = await Request().get( + final res = await Request.get( Api.favFolder, queryParameters: {'up_mid': mid}, ); @@ -724,7 +724,7 @@ abstract final class FavHttp { dynamic rid, dynamic type, }) async { - final res = await Request().get( + final res = await Request.get( Api.favFolder, queryParameters: { 'up_mid': mid, diff --git a/lib/http/follow.dart b/lib/http/follow.dart index bd19e2fc4..180f252c1 100644 --- a/lib/http/follow.dart +++ b/lib/http/follow.dart @@ -13,7 +13,7 @@ abstract final class FollowHttp { int ps = 20, String orderType = '', // ''=>最近关注,'attention'=>最常访问 }) async { - final res = await Request().get( + final res = await Request.get( Api.followings, queryParameters: { 'vmid': vmid, @@ -33,7 +33,7 @@ abstract final class FollowHttp { static Future> sortFollowTag({ required String tagids, }) async { - final res = await Request().post( + final res = await Request.post( Api.sortFollowTag, queryParameters: { 'x-bili-device-req-json': diff --git a/lib/http/init.dart b/lib/http/init.dart index c556bccb3..4dad4e978 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -17,18 +17,16 @@ import 'package:dio/dio.dart'; import 'package:dio/io.dart'; import 'package:dio_http2_adapter/dio_http2_adapter.dart'; -class Request { +abstract final class Request { static const _gzipDecoder = GZipDecoder(); static const _brotliDecoder = BrotliDecoder(); - static final Request _instance = Request._internal(); - static late AccountManager accountManager; + static late final AccountManager accountManager; static final _enableHttp2 = Pref.enableHttp2; static late final Dio dio; static Dio? _http11Dio; static Dio get http11Dio => _http11Dio ??= _enableHttp2 ? _cloneHttp11Dio() : dio; - factory Request() => _instance; /// 设置cookie static void setCookie() { @@ -42,7 +40,7 @@ class Request { if (coin == null) { setCoin(); } else { - GlobalData().coins = coin; + GlobalData.coins = coin; } } } @@ -50,7 +48,7 @@ class Request { static Future setCoin() async { final res = await UserHttp.getCoin(); if (res case Success(:final response)) { - GlobalData().coins = response; + GlobalData.coins = response; } } @@ -132,9 +130,9 @@ class Request { /* * config it and create */ - Request._internal() { + static void init() { //BaseOptions、Options、RequestOptions 都可以配置参数,优先级别依次递增,且可以根据优先级别覆盖参数 - BaseOptions options = BaseOptions( + final options = BaseOptions( //请求基地址,可以包含子路径 baseUrl: HttpString.apiBaseUrl, //连接服务器超时时间,单位是毫秒. @@ -186,7 +184,7 @@ class Request { /* * get请求 */ - Future get( + static Future get( String url, { Map? queryParameters, Options? options, @@ -213,7 +211,7 @@ class Request { /* * post请求 */ - Future post( + static Future post( String url, { Object? data, Map? queryParameters, @@ -244,7 +242,7 @@ class Request { /* * 下载文件 */ - Future downloadFile( + static Future downloadFile( String urlPath, String savePath, { CancelToken? cancelToken, diff --git a/lib/http/live.dart b/lib/http/live.dart index c7b0a154f..82e11e52a 100644 --- a/lib/http/live.dart +++ b/lib/http/live.dart @@ -43,7 +43,7 @@ abstract final class LiveHttp { String replayDmid = '', }) async { String csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( Api.sendLiveMsg, queryParameters: await WbiSign.makSign({ 'web_location': 444.8, @@ -85,7 +85,7 @@ abstract final class LiveHttp { Object? qn, bool onlyAudio = false, }) async { - final res = await Request().get( + final res = await Request.get( Api.liveRoomInfo, queryParameters: await WbiSign.makSign({ 'room_id': roomId, @@ -111,7 +111,7 @@ abstract final class LiveHttp { static Future> liveRoomInfoH5({ required Object roomId, }) async { - final res = await Request().get( + final res = await Request.get( Api.liveRoomInfoH5, queryParameters: { 'room_id': roomId, @@ -127,7 +127,7 @@ abstract final class LiveHttp { static Future?>> liveRoomDmPrefetch({ required Object roomId, }) async { - final res = await Request().get( + final res = await Request.get( Api.liveRoomDmPrefetch, queryParameters: {'roomid': roomId}, options: Options( @@ -155,7 +155,7 @@ abstract final class LiveHttp { static Future> liveRoomGetDanmakuToken({ required Object roomId, }) async { - final res = await Request().get( + final res = await Request.get( Api.liveRoomDmToken, queryParameters: await WbiSign.makSign({ 'id': roomId, @@ -172,7 +172,7 @@ abstract final class LiveHttp { static Future?>> getLiveEmoticons({ required int roomId, }) async { - final res = await Request().get( + final res = await Request.get( Api.getLiveEmoticons, queryParameters: { 'platform': 'pc', @@ -214,7 +214,7 @@ abstract final class LiveHttp { 'statistics': Constants.statisticsApp, }; AppSign.appSign(params); - final res = await Request().get( + final res = await Request.get( Api.liveFeedIndex, queryParameters: params, options: Options( @@ -243,7 +243,7 @@ abstract final class LiveHttp { } static Future> liveFollow(int page) async { - final res = await Request().get( + final res = await Request.get( Api.liveFollow, queryParameters: { 'page': page, @@ -294,7 +294,7 @@ abstract final class LiveHttp { 'statistics': Constants.statisticsApp, }; AppSign.appSign(params); - final res = await Request().get( + final res = await Request.get( Api.liveSecondList, queryParameters: params, options: Options( @@ -338,7 +338,7 @@ abstract final class LiveHttp { 'statistics': Constants.statisticsApp, }; AppSign.appSign(params); - final res = await Request().get( + final res = await Request.get( Api.liveAreaList, queryParameters: params, ); @@ -369,7 +369,7 @@ abstract final class LiveHttp { 'statistics': Constants.statisticsApp, }; AppSign.appSign(params); - final res = await Request().get( + final res = await Request.get( Api.getLiveFavTag, queryParameters: params, ); @@ -405,7 +405,7 @@ abstract final class LiveHttp { 'statistics': Constants.statisticsApp, }; AppSign.appSign(data); - final res = await Request().post( + final res = await Request.post( Api.setLiveFavTag, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -439,7 +439,7 @@ abstract final class LiveHttp { 'statistics': Constants.statisticsApp, }; AppSign.appSign(params); - final res = await Request().get( + final res = await Request.get( Api.liveRoomAreaList, queryParameters: params, ); @@ -476,7 +476,7 @@ abstract final class LiveHttp { 'type': type.name, }; AppSign.appSign(params); - final res = await Request().get( + final res = await Request.get( Api.liveSearch, queryParameters: params, ); @@ -490,7 +490,7 @@ abstract final class LiveHttp { static Future> getLiveInfoByUser( Object roomId, ) async { - final res = await Request().get( + final res = await Request.get( Api.getLiveInfoByUser, queryParameters: await WbiSign.makSign({ 'room_id': roomId, @@ -511,7 +511,7 @@ abstract final class LiveHttp { required int level, }) async { final csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( Api.liveSetSilent, data: { 'type': type, @@ -532,7 +532,7 @@ abstract final class LiveHttp { required String keyword, }) async { final csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( Api.addShieldKeyword, data: { 'keyword': keyword, @@ -552,7 +552,7 @@ abstract final class LiveHttp { required String keyword, }) async { final csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( Api.delShieldKeyword, data: { 'keyword': keyword, @@ -574,7 +574,7 @@ abstract final class LiveHttp { required int type, }) async { final csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( Api.liveShieldUser, data: { 'uid': uid, @@ -598,7 +598,7 @@ abstract final class LiveHttp { required Object uid, Object? anchorId, }) async { - final res = await Request().post( + final res = await Request.post( Api.liveLikeReport, data: await WbiSign.makSign({ 'click_time': clickTime, @@ -621,7 +621,7 @@ abstract final class LiveHttp { static Future> superChatMsg( Object roomId, ) async { - final res = await Request().get( + final res = await Request.get( Api.superChatMsg, queryParameters: { 'room_id': roomId, @@ -666,7 +666,7 @@ abstract final class LiveHttp { 'csrf': csrf, 'visit_id': '', }; - final res = await Request().post( + final res = await Request.post( Api.liveDmReport, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -684,7 +684,7 @@ abstract final class LiveHttp { required int page, required LiveContributionRankType type, }) async { - final res = await Request().get( + final res = await Request.get( Api.liveContributionRank, queryParameters: await WbiSign.makSign({ 'ruid': ruid, @@ -718,7 +718,7 @@ abstract final class LiveHttp { required String token, }) async { final csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( Api.superChatReport, data: { 'id': id, @@ -747,7 +747,7 @@ abstract final class LiveHttp { static Future> liveMedalWall({ required Object mid, }) async { - final res = await Request().get( + final res = await Request.get( Api.liveMedalWall, queryParameters: {'target_id': mid}, ); diff --git a/lib/http/login.dart b/lib/http/login.dart index 748183244..742358dea 100644 --- a/lib/http/login.dart +++ b/lib/http/login.dart @@ -40,7 +40,7 @@ abstract final class LoginHttp { 'mobi_app': 'android_hd', }; AppSign.appSign(params); - final res = await Request().post(Api.getTVCode, queryParameters: params); + final res = await Request.post(Api.getTVCode, queryParameters: params); if (res.data['code'] == 0) { try { @@ -60,7 +60,7 @@ abstract final class LoginHttp { 'local_id': '0', }; AppSign.appSign(params); - final res = await Request().post(Api.qrcodePoll, queryParameters: params); + final res = await Request.post(Api.qrcodePoll, queryParameters: params); return { 'status': res.data['code'] == 0, 'code': res.data['code'], @@ -70,7 +70,7 @@ abstract final class LoginHttp { } static Future queryCaptcha() async { - final res = await Request().get(Api.getCaptcha); + final res = await Request.get(Api.getCaptcha); if (res.data['code'] == 0) { return { 'status': true, @@ -83,7 +83,7 @@ abstract final class LoginHttp { // 获取salt与PubKey static Future getWebKey() async { - final res = await Request().get(Api.getWebKey); + final res = await Request.get(Api.getWebKey); //data: {'disable_rcmd': 0, 'local_id': LoginUtils.generateBuvid()}); if (res.data['code'] == 0) { return {'status': true, 'data': res.data['data']}; @@ -128,7 +128,7 @@ abstract final class LoginHttp { }; AppSign.appSign(data); - final res = await Request().post( + final res = await Request.post( Api.appSmsCode, data: data, options: Options( @@ -174,7 +174,7 @@ abstract final class LoginHttp { // Constants.appKey, // Constants.appSec, // ); - // final res = await Request().post(Api.getGuestId, + // final res = await Request.post(Api.getGuestId, // queryParameters: {...params, 'sign': sign}, // options: Options( // contentType: Headers.formUrlEncodedContentType, @@ -237,7 +237,7 @@ abstract final class LoginHttp { 'username': username, }; AppSign.appSign(data); - final res = await Request().post( + final res = await Request.post( Api.loginByPwdApi, data: data, options: Options( @@ -303,7 +303,7 @@ abstract final class LoginHttp { 'tel': tel, }; AppSign.appSign(data); - final res = await Request().post( + final res = await Request.post( Api.logInByAppSms, data: data, options: Options( @@ -329,7 +329,7 @@ abstract final class LoginHttp { static Future safeCenterGetInfo({ required String tmpCode, }) async { - final res = await Request().get( + final res = await Request.get( Api.safeCenterGetInfo, queryParameters: { 'tmp_code': tmpCode, @@ -349,7 +349,7 @@ abstract final class LoginHttp { // 风控验证手机前的极验验证码 static Future preCapture() async { - final res = await Request().post(Api.preCapture); + final res = await Request.post(Api.preCapture); if (res.data['code'] == 0) { return {'status': true, 'data': res.data['data']}; @@ -383,7 +383,7 @@ abstract final class LoginHttp { 'recaptcha_token': ?recaptchaToken, }; AppSign.appSign(data); - final res = await Request().post( + final res = await Request.post( Api.safeCenterSmsCode, data: data, options: Options( @@ -425,7 +425,7 @@ abstract final class LoginHttp { 'captcha_key': captchaKey, }; AppSign.appSign(data); - final res = await Request().post( + final res = await Request.post( Api.safeCenterSmsVerify, data: data, options: Options( @@ -471,7 +471,7 @@ abstract final class LoginHttp { // 'statistics': Constants.statistics, }; AppSign.appSign(data); - final res = await Request().post( + final res = await Request.post( Api.oauth2AccessToken, data: data, options: Options( @@ -493,7 +493,7 @@ abstract final class LoginHttp { } static Future logout(Account account) async { - final res = await Request().post( + final res = await Request.post( Api.logout, data: {'biliCSRF': account.csrf}, options: Options( @@ -519,7 +519,7 @@ abstract final class LoginHttp { 'statistics': Constants.statistics, }; AppSign.appSign(params); - final res = await Request().get( + final res = await Request.get( Api.loginDevices, queryParameters: params, ); diff --git a/lib/http/match.dart b/lib/http/match.dart index 84a2d487c..d79861ecb 100644 --- a/lib/http/match.dart +++ b/lib/http/match.dart @@ -6,7 +6,7 @@ import 'package:PiliPlus/models_new/match/match_info/data.dart'; abstract final class MatchHttp { static Future> matchInfo(Object cid) async { - final res = await Request().get( + final res = await Request.get( Api.matchInfo, queryParameters: { 'cid': cid, diff --git a/lib/http/member.dart b/lib/http/member.dart index e6fc13b83..1ef7b2abc 100644 --- a/lib/http/member.dart +++ b/lib/http/member.dart @@ -44,7 +44,7 @@ abstract final class MemberHttp { String? reason, int? reasonV2, }) async { - final res = await Request().post( + final res = await Request.post( Api.reportMember, data: { 'mid': mid, @@ -78,7 +78,7 @@ abstract final class MemberHttp { 'statistics': Constants.statisticsApp, 'vmid': mid, }; - final res = await Request().get( + final res = await Request.get( Api.spaceArticle, queryParameters: params, options: Options( @@ -99,7 +99,7 @@ abstract final class MemberHttp { required int? mid, required int pn, }) async { - final res = await Request().get( + final res = await Request.get( Api.seasonSeries, queryParameters: { 'mid': mid, @@ -149,7 +149,7 @@ abstract final class MemberHttp { 'statistics': Constants.statisticsApp, 'vmid': mid, }; - final res = await Request().get( + final res = await Request.get( type.api, queryParameters: params, options: Options( @@ -170,7 +170,7 @@ abstract final class MemberHttp { required int page, required mid, }) async { - final res = await Request().get( + final res = await Request.get( Api.spaceAudio, queryParameters: { 'pn': page, @@ -191,7 +191,7 @@ abstract final class MemberHttp { required int page, required mid, }) async { - final res = await Request().get( + final res = await Request.get( Api.spaceCheese, queryParameters: { 'pn': page, @@ -233,7 +233,7 @@ abstract final class MemberHttp { // 'statistics': Constants.statisticsApp, // 'vmid': mid, // }; - // final res = await Request().get( + // final res = await Request.get( // Api.spaceStory, // queryParameters: params, // options: Options( @@ -266,7 +266,7 @@ abstract final class MemberHttp { 'statistics': Constants.statisticsApp, 'vmid': mid, }; - final res = await Request().get( + final res = await Request.get( Api.space, queryParameters: params, options: Options( @@ -299,7 +299,7 @@ abstract final class MemberHttp { 'dm_cover_img_str': dmCoverImgStr, 'dm_img_inter': '{"ds":[],"wh":[0,0,0],"of":[0,0,0]}', }); - final res = await Request().get( + final res = await Request.get( Api.memberInfo, queryParameters: params, options: Options( @@ -318,7 +318,7 @@ abstract final class MemberHttp { } static Future> memberStat({int? mid}) async { - final res = await Request().get( + final res = await Request.get( Api.userStat, queryParameters: {'vmid': mid}, ); @@ -332,7 +332,7 @@ abstract final class MemberHttp { static Future> memberCardInfo({ int? mid, }) async { - final res = await Request().get( + final res = await Request.get( Api.memberCardInfo, queryParameters: { 'mid': mid, @@ -373,7 +373,7 @@ abstract final class MemberHttp { 'dm_cover_img_str': dmCoverImgStr, 'dm_img_inter': '{"ds":[],"wh":[0,0,0],"of":[0,0,0]}', }); - final res = await Request().get( + final res = await Request.get( Api.searchArchive, queryParameters: params, options: Options( @@ -399,7 +399,7 @@ abstract final class MemberHttp { required int pn, ArchiveSortTypeApp sort = .desc, }) async { - final res = await Request().get( + final res = await Request.get( type.api, queryParameters: switch (type) { .season => { @@ -456,7 +456,7 @@ abstract final class MemberHttp { 'x-bili-device-req-json': '{"platform":"web","device":"pc","spmid":"333.1387"}', }); - final res = await Request().get( + final res = await Request.get( Api.memberDynamic, queryParameters: params, options: Options( @@ -488,7 +488,7 @@ abstract final class MemberHttp { required dynamic offset, required String keyword, }) async { - final res = await Request().get( + final res = await Request.get( Api.dynSearch, queryParameters: { 'host_mid': mid, @@ -508,7 +508,7 @@ abstract final class MemberHttp { // 查询分组 static Future>> followUpTags() async { - final res = await Request().get(Api.followUpTag); + final res = await Request.get(Api.followUpTag); if (res.data['code'] == 0) { return Success( (res.data['data'] as List) @@ -524,7 +524,7 @@ abstract final class MemberHttp { int? fid, bool isAdd = true, }) async { - final res = await Request().post( + final res = await Request.post( isAdd ? Api.addSpecial : Api.delSpecial, data: { 'fid': fid, @@ -541,7 +541,7 @@ abstract final class MemberHttp { // 设置分组 static Future> addUsers(String fids, String tagids) async { - final res = await Request().post( + final res = await Request.post( Api.addUsers, queryParameters: { 'x-bili-device-req-json': @@ -569,7 +569,7 @@ abstract final class MemberHttp { int? pn, int ps = 20, }) async { - final res = await Request().get( + final res = await Request.get( Api.followUpGroup, queryParameters: { 'mid': mid, @@ -594,7 +594,7 @@ abstract final class MemberHttp { } static Future> createFollowTag(String tagName) async { - final res = await Request().post( + final res = await Request.post( Api.createFollowTag, queryParameters: { 'x-bili-device-req-json': @@ -617,7 +617,7 @@ abstract final class MemberHttp { Object tagid, Object name, ) async { - final res = await Request().post( + final res = await Request.post( Api.updateFollowTag, queryParameters: { 'x-bili-device-req-json': @@ -638,7 +638,7 @@ abstract final class MemberHttp { } static Future> delFollowTag(Object tagid) async { - final res = await Request().post( + final res = await Request.post( Api.delFollowTag, queryParameters: { 'x-bili-device-req-json': @@ -659,7 +659,7 @@ abstract final class MemberHttp { // 获取up置顶 static Future?>> getTopVideo() async { - final res = await Request().get(Api.getTopVideoApi); + final res = await Request.get(Api.getTopVideoApi); if (res.data['code'] == 0) { return Success( (res.data['data'] as List?) @@ -673,7 +673,7 @@ abstract final class MemberHttp { // 获取up播放数、点赞数 static Future> memberView({required int mid}) async { - final res = await Request().get( + final res = await Request.get( Api.getMemberViewApi, queryParameters: {'mid': mid}, ); @@ -702,7 +702,7 @@ abstract final class MemberHttp { 'web_location': 333.999, }; Map params = await WbiSign.makSign(data); - final res = await Request().get( + final res = await Request.get( Api.followSearch, queryParameters: { ...data, @@ -723,7 +723,7 @@ abstract final class MemberHttp { String offset = '', String type = 'all', }) async { - final res = await Request().get( + final res = await Request.get( Api.spaceOpus, queryParameters: await WbiSign.makSign({ 'host_mid': hostMid, @@ -745,7 +745,7 @@ abstract final class MemberHttp { required int page, int? privilegeType, }) async { - final res = await Request().get( + final res = await Request.get( Api.upowerRank, queryParameters: { 'up_mid': upMid, @@ -768,7 +768,7 @@ abstract final class MemberHttp { required int mid, required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.coinArc, queryParameters: { 'pn': page, @@ -787,7 +787,7 @@ abstract final class MemberHttp { required int mid, required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.likeArc, queryParameters: { 'pn': page, @@ -814,7 +814,7 @@ abstract final class MemberHttp { 'statistics': Constants.statisticsApp, }; AppSign.appSign(params); - final res = await Request().post( + final res = await Request.post( Api.spaceShop, queryParameters: params, data: { @@ -836,7 +836,7 @@ abstract final class MemberHttp { required Object ruid, required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.memberGuard, queryParameters: { 'page': page, diff --git a/lib/http/msg.dart b/lib/http/msg.dart index b52009ed3..64d3ec0c8 100644 --- a/lib/http/msg.dart +++ b/lib/http/msg.dart @@ -24,7 +24,7 @@ abstract final class MsgHttp { int? cursor, int? cursorTime, }) async { - final res = await Request().get( + final res = await Request.get( Api.msgFeedReply, queryParameters: { 'id': ?cursor, @@ -46,7 +46,7 @@ abstract final class MsgHttp { int? cursor, int? cursorTime, }) async { - final res = await Request().get( + final res = await Request.get( Api.msgFeedAt, queryParameters: { 'id': ?cursor, @@ -68,7 +68,7 @@ abstract final class MsgHttp { int? cursor, int? cursorTime, }) async { - final res = await Request().get( + final res = await Request.get( Api.msgFeedLike, queryParameters: { 'id': ?cursor, @@ -91,7 +91,7 @@ abstract final class MsgHttp { required int pn, Object lastMid = 0, }) async { - final res = await Request().get( + final res = await Request.get( Api.msgLikeDetail, queryParameters: { 'card_id': cardId, @@ -114,7 +114,7 @@ abstract final class MsgHttp { int? cursor, int pageSize = 20, }) async { - final res = await Request().get( + final res = await Request.get( Api.msgSysNotify, queryParameters: { 'cursor': ?cursor, @@ -137,7 +137,7 @@ abstract final class MsgHttp { static Future> msgSysUpdateCursor(int cursor) async { String csrf = Accounts.main.csrf; - final res = await Request().get( + final res = await Request.get( Api.msgSysUpdateCursor, queryParameters: { 'csrf': csrf, @@ -156,7 +156,7 @@ abstract final class MsgHttp { required String bucket, required String dir, }) async { - final res = await Request().post( + final res = await Request.post( Api.uploadImage, data: FormData.fromMap({ 'bucket': bucket, @@ -178,7 +178,7 @@ abstract final class MsgHttp { String? biz, CancelToken? cancelToken, }) async { - final res = await Request().post( + final res = await Request.post( Api.uploadBfs, data: FormData.fromMap({ 'file_up': await MultipartFile.fromFile(path), @@ -207,7 +207,7 @@ abstract final class MsgHttp { 'csrf_token': csrf, 'csrf': csrf, }); - final res = await Request().post( + final res = await Request.post( HttpString.tUrl + Api.createTextDynamic, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -224,7 +224,7 @@ abstract final class MsgHttp { Object? dynType, Object? ridStr, }) async { - final res = await Request().post( + final res = await Request.post( Api.removeDynamic, queryParameters: { 'platform': 'web', @@ -255,7 +255,7 @@ abstract final class MsgHttp { 'csrf_token': csrf, 'csrf': csrf, }); - final res = await Request().post( + final res = await Request.post( HttpString.tUrl + Api.removeMsg, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -272,7 +272,7 @@ abstract final class MsgHttp { dynamic id, ) async { String csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( Api.delMsgfeed, data: { 'tp': tp, @@ -295,7 +295,7 @@ abstract final class MsgHttp { Object id, ) async { String csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( HttpString.messageBaseUrl + Api.delSysMsg, queryParameters: { 'mobi_app': 'android', @@ -330,7 +330,7 @@ abstract final class MsgHttp { 'csrf_token': csrf, 'csrf': csrf, }); - final res = await Request().post( + final res = await Request.post( HttpString.tUrl + Api.setTop, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -357,7 +357,7 @@ abstract final class MsgHttp { 'csrf_token': csrf, 'csrf': csrf, }); - final res = await Request().get(Api.ackSessionMsg, queryParameters: params); + final res = await Request.get(Api.ackSessionMsg, queryParameters: params); if (res.data['code'] == 0) { return const Success(null); } else { @@ -397,7 +397,7 @@ abstract final class MsgHttp { // 'csrf': csrf, // }; // Map params = await WbiSign.makSign(data); - // final res = await Request().post( + // final res = await Request.post( // Api.sendMsg, // queryParameters: { // 'w_sender_uid': senderUid, @@ -427,7 +427,7 @@ abstract final class MsgHttp { required int noticeState, }) async { final csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( Api.msgSetNotice, data: { 'mobi_app': 'web', @@ -456,7 +456,7 @@ abstract final class MsgHttp { required dndUid, }) async { final csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( Api.setMsgDnd, data: { 'uid': uid, @@ -481,7 +481,7 @@ abstract final class MsgHttp { required talkerUid, }) async { final csrf = Accounts.main.csrf; - final res = await Request().post( + final res = await Request.post( Api.setPushSs, data: { 'setting': setting, @@ -504,7 +504,7 @@ abstract final class MsgHttp { required String uids, }) async { final csrf = Accounts.main.csrf; - final res = await Request().get( + final res = await Request.get( Api.imUserInfos, queryParameters: { 'uids': uids, @@ -529,7 +529,7 @@ abstract final class MsgHttp { required Object talkerUid, }) async { final csrf = Accounts.main.csrf; - final res = await Request().get( + final res = await Request.get( Api.getSessionSs, queryParameters: { 'talker_uid': talkerUid, @@ -550,7 +550,7 @@ abstract final class MsgHttp { required Object uidsStr, }) async { final csrf = Accounts.main.csrf; - final res = await Request().get( + final res = await Request.get( Api.getMsgDnd, queryParameters: { 'own_uid': Accounts.main.mid, @@ -573,7 +573,7 @@ abstract final class MsgHttp { } static Future> msgUnread() async { - final res = await Request().get( + final res = await Request.get( Api.msgUnread, queryParameters: { 'build': 0, @@ -590,7 +590,7 @@ abstract final class MsgHttp { } static Future> msgFeedUnread() async { - final res = await Request().get( + final res = await Request.get( Api.msgFeedUnread, queryParameters: { 'build': 0, @@ -612,7 +612,7 @@ abstract final class MsgHttp { required Map comment, required Map extra, }) async { - final res = await Request().post( + final res = await Request.post( Api.imMsgReport, data: { 'biz_code': 4, diff --git a/lib/http/music.dart b/lib/http/music.dart index 4a33fadb3..d6a228596 100644 --- a/lib/http/music.dart +++ b/lib/http/music.dart @@ -9,7 +9,7 @@ import 'package:dio/dio.dart'; abstract final class MusicHttp { static Future> bgmDetail(String musicId) async { - final res = await Request().get( + final res = await Request.get( Api.bgmDetail, queryParameters: await WbiSign.makSign({ 'music_id': musicId, @@ -27,7 +27,7 @@ abstract final class MusicHttp { String musicId, bool hasLike, ) async { - final res = await Request().post( + final res = await Request.post( Api.wishUpdate, data: { 'music_id': musicId, @@ -46,7 +46,7 @@ abstract final class MusicHttp { static Future?>> bgmRecommend( String musicId, ) async { - final res = await Request().get( + final res = await Request.get( Api.bgmRecommend, queryParameters: { 'music_id': musicId, diff --git a/lib/http/pgc.dart b/lib/http/pgc.dart index 1fe0f54fa..fbb83fab0 100644 --- a/lib/http/pgc.dart +++ b/lib/http/pgc.dart @@ -19,7 +19,7 @@ abstract final class PgcHttp { type, indexType, }) async { - final res = await Request().get( + final res = await Request.get( Api.pgcIndexResult, queryParameters: { ...params, @@ -42,7 +42,7 @@ abstract final class PgcHttp { required Object type, Object? indexType, }) async { - final res = await Request().get( + final res = await Request.get( Api.pgcIndexCondition, queryParameters: { 'season_type': ?seasonType, @@ -61,7 +61,7 @@ abstract final class PgcHttp { int? page, int? indexType, }) async { - final res = await Request().get( + final res = await Request.get( Api.pgcIndexResult, queryParameters: { 'st': 1, @@ -95,7 +95,7 @@ abstract final class PgcHttp { required int before, required int after, }) async { - final res = await Request().get( + final res = await Request.get( Api.pgcTimeline, queryParameters: { 'types': types, @@ -116,7 +116,7 @@ abstract final class PgcHttp { int sort = 0, String? next, }) async { - final res = await Request().get( + final res = await Request.get( type.api, queryParameters: { 'media_id': mediaId, @@ -137,7 +137,7 @@ abstract final class PgcHttp { required Object mediaId, required Object reviewId, }) async { - final res = await Request().post( + final res = await Request.post( Api.pgcReviewLike, data: { 'media_id': mediaId, @@ -158,7 +158,7 @@ abstract final class PgcHttp { required Object mediaId, required Object reviewId, }) async { - final res = await Request().post( + final res = await Request.post( Api.pgcReviewDislike, data: { 'media_id': mediaId, @@ -181,7 +181,7 @@ abstract final class PgcHttp { required String content, bool shareFeed = false, }) async { - final res = await Request().post( + final res = await Request.post( Api.pgcReviewPost, data: { 'media_id': mediaId, @@ -205,7 +205,7 @@ abstract final class PgcHttp { required String content, required reviewId, }) async { - final res = await Request().post( + final res = await Request.post( Api.pgcReviewMod, data: { 'media_id': mediaId, @@ -227,7 +227,7 @@ abstract final class PgcHttp { required Object mediaId, required Object reviewId, }) async { - final res = await Request().post( + final res = await Request.post( Api.pgcReviewDel, data: { 'media_id': mediaId, @@ -244,7 +244,7 @@ abstract final class PgcHttp { } static Future> seasonStatus(Object seasonId) async { - final res = await Request().get( + final res = await Request.get( Api.seasonStatus, queryParameters: {'season_id': seasonId}, ); diff --git a/lib/http/reply.dart b/lib/http/reply.dart index db9bc1009..ed2ca6cef 100644 --- a/lib/http/reply.dart +++ b/lib/http/reply.dart @@ -27,7 +27,7 @@ abstract final class ReplyHttp { int sort = 1, }) async { final res = !isLogin - ? await Request().get( + ? await Request.get( '${Api.replyList}/main', queryParameters: { 'oid': oid, @@ -38,7 +38,7 @@ abstract final class ReplyHttp { }, options: !isLogin ? options : null, ) - : await Request().get( + : await Request.get( Api.replyList, queryParameters: { 'oid': oid, @@ -64,7 +64,7 @@ abstract final class ReplyHttp { required int type, bool isCheck = false, }) async { - final res = await Request().get( + final res = await Request.get( Api.replyReplyList, queryParameters: { 'oid': oid, @@ -94,7 +94,7 @@ abstract final class ReplyHttp { required int oid, required int rpid, }) async { - final res = await Request().post( + final res = await Request.post( Api.hateReply, data: { 'type': type, @@ -119,7 +119,7 @@ abstract final class ReplyHttp { required int rpid, required int action, }) async { - final res = await Request().post( + final res = await Request.post( Api.likeReply, data: { 'type': type, @@ -140,7 +140,7 @@ abstract final class ReplyHttp { static Future?>> getEmoteList({ String? business, }) async { - final res = await Request().get( + final res = await Request.get( Api.myEmote, queryParameters: { 'business': business ?? 'reply', @@ -160,7 +160,7 @@ abstract final class ReplyHttp { required Object rpid, required bool isUpTop, }) async { - final res = await Request().post( + final res = await Request.post( Api.replyTop, data: { 'oid': oid, @@ -185,7 +185,7 @@ abstract final class ReplyHttp { bool banUid = true, String? reasonDesc, }) async { - final res = await Request().post( + final res = await Request.post( '/x/v2/reply/report', data: { 'add_blacklist': banUid, @@ -213,7 +213,7 @@ abstract final class ReplyHttp { required Object oid, required Object type, }) async { - final res = await Request().get( + final res = await Request.get( Api.replyInteraction, queryParameters: { 'oid': oid, @@ -237,7 +237,7 @@ abstract final class ReplyHttp { required int type, required int action, }) async { - final res = await Request().post( + final res = await Request.post( Api.replySubjectModify, data: { 'oid': oid, diff --git a/lib/http/search.dart b/lib/http/search.dart index d2040f755..175e1ccff 100644 --- a/lib/http/search.dart +++ b/lib/http/search.dart @@ -23,7 +23,7 @@ abstract final class SearchHttp { static Future> searchSuggest({ required String term, }) async { - final res = await Request().get( + final res = await Request.get( Api.searchSuggest, queryParameters: { 'term': term, @@ -76,7 +76,7 @@ abstract final class SearchHttp { 'web_location': 1430654, 'gaia_vtoken': ?gaiaVtoken, }); - final res = await Request().get( + final res = await Request.get( Api.searchByType, queryParameters: params, options: Options( @@ -155,7 +155,7 @@ abstract final class SearchHttp { 'pubtime_begin_s': ?pubBegin, 'pubtime_end_s': ?pubEnd, }); - final res = await Request().get( + final res = await Request.get( Api.searchAll, queryParameters: params, ); @@ -182,7 +182,7 @@ abstract final class SearchHttp { dynamic bvid, int? part, }) async { - final res = await Request().get( + final res = await Request.get( Api.ab2c, queryParameters: { 'aid': ?aid, @@ -214,7 +214,7 @@ abstract final class SearchHttp { dynamic seasonId, dynamic epId, }) async { - final res = await Request().get( + final res = await Request.get( Api.pgcInfo, queryParameters: { 'season_id': ?seasonId, @@ -232,7 +232,7 @@ abstract final class SearchHttp { dynamic seasonId, dynamic epId, }) async { - final res = await Request().get( + final res = await Request.get( Api.pugvInfo, queryParameters: { 'season_id': ?seasonId, @@ -247,7 +247,7 @@ abstract final class SearchHttp { } // static Future episodeInfo({dynamic epId}) async { - // final res = await Request().get( + // final res = await Request.get( // Api.episodeInfo, // queryParameters: { // 'ep_id': ?epId, @@ -263,7 +263,7 @@ abstract final class SearchHttp { static Future> searchTrending({ int limit = 30, }) async { - final res = await Request().get( + final res = await Request.get( Api.searchTrending, queryParameters: { 'limit': limit, @@ -277,7 +277,7 @@ abstract final class SearchHttp { } static Future> searchRecommend() async { - final res = await Request().get( + final res = await Request.get( Api.searchRecommend, queryParameters: { 'build': 8430300, @@ -302,7 +302,7 @@ abstract final class SearchHttp { String content = '', required int pageNum, }) async { - final res = await Request().get( + final res = await Request.get( Api.topicPubSearch, queryParameters: { 'keywords': keywords, diff --git a/lib/http/sponsor_block.dart b/lib/http/sponsor_block.dart index 752f81249..9cfe4c27b 100644 --- a/lib/http/sponsor_block.dart +++ b/lib/http/sponsor_block.dart @@ -48,7 +48,7 @@ abstract final class SponsorBlock { required String bvid, required int cid, }) async { - final res = await Request().get( + final res = await Request.get( _api(SponsorBlockApi.skipSegments), queryParameters: { 'videoID': bvid, @@ -71,7 +71,7 @@ abstract final class SponsorBlock { SegmentType? category, }) async { assert((type == null) == (category == null)); - final res = await Request().post( + final res = await Request.post( _api(SponsorBlockApi.voteOnSponsorTime), queryParameters: { 'UUID': uuid, @@ -85,7 +85,7 @@ abstract final class SponsorBlock { } static Future> viewedVideoSponsorTime(String uuid) async { - final res = await Request().post( + final res = await Request.post( _api(SponsorBlockApi.viewedVideoSponsorTime), data: {'UUID': uuid}, options: options, @@ -94,7 +94,7 @@ abstract final class SponsorBlock { } static Future> uptimeStatus() async { - final res = await Request().get( + final res = await Request.get( _api(SponsorBlockApi.uptimeStatus), options: options, ); @@ -110,7 +110,7 @@ abstract final class SponsorBlock { List query, { String? userId, }) async { - final res = await Request().get( + final res = await Request.get( _api(SponsorBlockApi.userInfo), queryParameters: { 'userID': userId ?? Pref.blockUserID, @@ -130,7 +130,7 @@ abstract final class SponsorBlock { required double videoDuration, required List segments, }) async { - final res = await Request().post( + final res = await Request.post( _api(SponsorBlockApi.skipSegments), data: { 'videoID': bvid, @@ -172,7 +172,7 @@ abstract final class SponsorBlock { required String bvid, required int cid, }) async { - final res = await Request().get( + final res = await Request.get( _api(SponsorBlockApi.portVideo), queryParameters: { 'videoID': bvid, @@ -197,7 +197,7 @@ abstract final class SponsorBlock { required String ytbId, required int videoDuration, }) async { - final res = await Request().post( + final res = await Request.post( _api(SponsorBlockApi.portVideo), data: { 'bvID': bvid, diff --git a/lib/http/user.dart b/lib/http/user.dart index a5110789c..4c7fb2eaa 100644 --- a/lib/http/user.dart +++ b/lib/http/user.dart @@ -24,7 +24,7 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; abstract final class UserHttp { // static Future userStat({required int mid}) async { - // final res = await Request().get( + // final res = await Request.get( // Api.userStat, // queryParameters: {'vmid': mid}, // ); @@ -36,10 +36,10 @@ abstract final class UserHttp { // } static Future> userInfo() async { - final res = await Request().get(Api.userInfo); + final res = await Request.get(Api.userInfo); if (res.data['code'] == 0) { UserInfoData data = UserInfoData.fromJson(res.data['data']); - GlobalData().coins = data.money; + GlobalData.coins = data.money; return Success(data); } else { return Error(res.data['message']); @@ -47,7 +47,7 @@ abstract final class UserHttp { } static Future> userStatOwner() async { - final res = await Request().get(Api.userStatOwner); + final res = await Request.get(Api.userStatOwner); if (res.data['code'] == 0) { return Success(UserStat.fromJson(res.data['data'])); } else { @@ -62,7 +62,7 @@ abstract final class UserHttp { String keyword = '', bool asc = false, }) async { - final res = await Request().get( + final res = await Request.get( Api.seeYouLater, queryParameters: await WbiSign.makSign({ 'pn': page, @@ -88,7 +88,7 @@ abstract final class UserHttp { int? viewAt, Account? account, }) async { - final res = await Request().get( + final res = await Request.get( Api.historyList, queryParameters: { 'type': type, @@ -112,7 +112,7 @@ abstract final class UserHttp { }) async { // 暂停switchStatus传true 否则false account ??= Accounts.history; - final res = await Request().post( + final res = await Request.post( Api.pauseHistory, data: { 'switch': switchStatus, @@ -133,7 +133,7 @@ abstract final class UserHttp { // 观看历史暂停状态 static Future> historyStatus({Account? account}) async { - final res = await Request().get( + final res = await Request.get( Api.historyStatus, options: Options(extra: {'account': account ?? Accounts.history}), ); @@ -147,7 +147,7 @@ abstract final class UserHttp { // 清空历史记录 static Future> clearHistory({Account? account}) async { account ??= Accounts.history; - final res = await Request().post( + final res = await Request.post( Api.clearHistory, data: { 'jsonp': 'jsonp', @@ -171,7 +171,7 @@ abstract final class UserHttp { Object? aid, }) async { assert(aid != null || bvid != null); - final res = await Request().post( + final res = await Request.post( Api.toViewLater, data: { 'aid': ?aid, @@ -195,7 +195,7 @@ abstract final class UserHttp { 'csrf': Accounts.main.csrf, 'resources': aids, }; - final res = await Request().post( + final res = await Request.post( Api.toViewDel, data: params, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -211,7 +211,7 @@ abstract final class UserHttp { // 获取用户凭证 失效 // static Future thirdLogin() async { - // final res = await Request().get( + // final res = await Request.get( // 'https://passport.bilibili.com/login/app/third', // queryParameters: { // 'appkey': Constants.appKey, @@ -221,7 +221,7 @@ abstract final class UserHttp { // ); // try { // if (res.data['code'] == 0 && res.data['data']['has_login'] == 1) { - // Request().get(res.data['data']['confirm_uri']); + // Request.get(res.data['data']['confirm_uri']); // } // } catch (err) { // SmartDialog.showNotify(msg: '获取用户凭证: $err', notifyType: NotifyType.error); @@ -230,7 +230,7 @@ abstract final class UserHttp { // 清空稍后再看 // clean_type: null->all, 1->invalid, 2->viewed static Future> toViewClear([int? cleanType]) async { - final res = await Request().post( + final res = await Request.post( Api.toViewClear, data: { 'clean_type': ?cleanType, @@ -251,7 +251,7 @@ abstract final class UserHttp { Account? account, }) async { account ??= Accounts.history; - final res = await Request().post( + final res = await Request.post( Api.delHistory, data: { 'kid': kid, @@ -271,7 +271,7 @@ abstract final class UserHttp { } static Future> userRelation(int mid) async { - final res = await Request().get( + final res = await Request.get( Api.relation, queryParameters: { 'fid': mid, @@ -290,7 +290,7 @@ abstract final class UserHttp { required String keyword, Account? account, }) async { - final res = await Request().get( + final res = await Request.get( Api.searchHistory, queryParameters: { 'pn': pn, @@ -312,7 +312,7 @@ abstract final class UserHttp { required int pn, required int ps, }) async { - final res = await Request().get( + final res = await Request.get( Api.userSubFolder, queryParameters: { 'up_mid': mid, @@ -332,7 +332,7 @@ abstract final class UserHttp { required String bvid, Object? cid, }) async { - final res = await Request().get( + final res = await Request.get( Api.videoTags, queryParameters: {'bvid': bvid, 'cid': ?cid}, ); @@ -359,7 +359,7 @@ abstract final class UserHttp { dynamic sortField = 1, bool direction = false, }) async { - final res = await Request().get( + final res = await Request.get( Api.mediaList, queryParameters: { 'mobi_app': 'web', @@ -383,7 +383,7 @@ abstract final class UserHttp { } static Future> getCoin() async { - final res = await Request().get(Api.getCoin); + final res = await Request.get(Api.getCoin); if (res.data['code'] == 0) { return Success(res.data['data']?['money']); } else { @@ -397,7 +397,7 @@ abstract final class UserHttp { required int reasonType, String? reasonDesc, }) async { - final res = await Request().post( + final res = await Request.post( Api.dynamicReport, queryParameters: { 'csrf': Accounts.main.csrf, @@ -418,7 +418,7 @@ abstract final class UserHttp { } static Future> spaceSetting() async { - final res = await Request().get( + final res = await Request.get( Api.spaceSetting, queryParameters: { 'mid': Accounts.main.mid, @@ -434,7 +434,7 @@ abstract final class UserHttp { static Future> spaceSettingMod( Map data, ) async { - final res = await Request().post( + final res = await Request.post( Api.spaceSettingMod, queryParameters: { 'csrf': Accounts.main.csrf, @@ -450,7 +450,7 @@ abstract final class UserHttp { } static Future> vipExpAdd() async { - final res = await Request().post( + final res = await Request.post( Api.vipExpAdd, queryParameters: { 'mid': Accounts.main.mid, @@ -465,7 +465,7 @@ abstract final class UserHttp { } static Future> coinLog() async { - final res = await Request().get( + final res = await Request.get( Api.coinLog, queryParameters: { 'jsonp': 'jsonp', @@ -480,7 +480,7 @@ abstract final class UserHttp { } static Future> loginLog() async { - final res = await Request().get( + final res = await Request.get( Api.loginLog, queryParameters: { 'jsonp': 'jsonp', @@ -495,7 +495,7 @@ abstract final class UserHttp { } static Future> expLog() async { - final res = await Request().get( + final res = await Request.get( Api.expLog, queryParameters: { 'jsonp': 'jsonp', @@ -517,7 +517,7 @@ abstract final class UserHttp { 'up_mid': mid, }; AppSign.appSign(params); - final res = await Request().get( + final res = await Request.get( Api.userRealName, queryParameters: params, ); @@ -532,7 +532,7 @@ abstract final class UserHttp { required Object mid, required int pn, }) async { - final res = await Request().get( + final res = await Request.get( Api.followedUp, queryParameters: { 'csrf': Accounts.main.csrf, @@ -554,7 +554,7 @@ abstract final class UserHttp { required Object mid, int? pn, }) async { - final res = await Request().get( + final res = await Request.get( Api.sameFollowing, queryParameters: { 'csrf': Accounts.main.csrf, @@ -576,7 +576,7 @@ abstract final class UserHttp { required Object sid, required bool isFollow, }) async { - final res = await Request().post( + final res = await Request.post( isFollow ? Api.spaceReserveCancel : Api.spaceReserve, data: { 'sid': sid, diff --git a/lib/http/validate.dart b/lib/http/validate.dart index 590a3a97c..53f13f0ed 100644 --- a/lib/http/validate.dart +++ b/lib/http/validate.dart @@ -6,7 +6,7 @@ import 'package:dio/dio.dart'; abstract final class ValidateHttp { static Future> gaiaVgateRegister(String vVoucher) async { - final res = await Request().post( + final res = await Request.post( Api.gaiaVgateRegister, queryParameters: { if (Accounts.main.isLogin) 'csrf': Accounts.main.csrf, @@ -31,7 +31,7 @@ abstract final class ValidateHttp { required dynamic token, required dynamic validate, }) async { - final res = await Request().post( + final res = await Request.post( Api.gaiaVgateValidate, queryParameters: { if (Accounts.main.isLogin) 'csrf': Accounts.main.csrf, diff --git a/lib/http/video.dart b/lib/http/video.dart index 10d5b66c5..3c42e41a3 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -46,7 +46,7 @@ abstract final class VideoHttp { required int ps, required int freshIdx, }) async { - final res = await Request().get( + final res = await Request.get( Api.recommendListWeb, queryParameters: await WbiSign.makSign({ 'version': 1, @@ -102,7 +102,7 @@ abstract final class VideoHttp { 'statistics': Constants.statistics, 'voice_balance': 0, }; - final res = await Request().get( + final res = await Request.get( Api.recommendListApp, queryParameters: params, options: Options( @@ -143,7 +143,7 @@ abstract final class VideoHttp { required int pn, required int ps, }) async { - final res = await Request().get( + final res = await Request.get( Api.hotList, queryParameters: {'pn': pn, 'ps': ps}, ); @@ -198,7 +198,7 @@ abstract final class VideoHttp { }); try { - final res = await Request().get(videoType.api, queryParameters: params); + final res = await Request.get(videoType.api, queryParameters: params); if (res.data['code'] == 0) { late PlayUrlModel data; @@ -250,7 +250,7 @@ abstract final class VideoHttp { static Future> videoIntro({ required String bvid, }) async { - final res = await Request().get( + final res = await Request.get( Api.videoIntro, queryParameters: {'bvid': bvid}, ); @@ -265,7 +265,7 @@ abstract final class VideoHttp { static Future> videoRelation({ required String bvid, }) async { - final res = await Request().get( + final res = await Request.get( Api.videoRelation, queryParameters: {'aid': IdUtils.bv2av(bvid), 'bvid': bvid}, ); @@ -280,7 +280,7 @@ abstract final class VideoHttp { static Future?>> relatedVideoList({ required String bvid, }) async { - final res = await Request().get( + final res = await Request.get( Api.relatedList, queryParameters: {'bvid': bvid}, ); @@ -299,7 +299,7 @@ abstract final class VideoHttp { static Future> pgcLikeCoinFav({ required Object epId, }) async { - final res = await Request().get( + final res = await Request.get( Api.pgcLikeCoinFav, queryParameters: {'ep_id': epId}, ); @@ -316,7 +316,7 @@ abstract final class VideoHttp { required int multiply, int selectLike = 0, }) async { - final res = await Request().post( + final res = await Request.post( Api.coinVideo, data: { 'aid': IdUtils.bv2av(bvid).toString(), @@ -339,7 +339,7 @@ abstract final class VideoHttp { required Object epId, Object? seasonId, }) async { - final res = await Request().post( + final res = await Request.post( Api.pgcTriple, data: {'ep_id': epId, 'csrf': Accounts.main.csrf}, options: Options( @@ -363,7 +363,7 @@ abstract final class VideoHttp { static Future> ugcTriple({ required String bvid, }) async { - final res = await Request().post( + final res = await Request.post( Api.ugcTriple, data: { 'aid': IdUtils.bv2av(bvid), @@ -396,7 +396,7 @@ abstract final class VideoHttp { required String bvid, required bool type, }) async { - final res = await Request().post( + final res = await Request.post( Api.likeVideo, data: {'aid': IdUtils.bv2av(bvid).toString(), 'like': type ? '0' : '1'}, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -416,7 +416,7 @@ abstract final class VideoHttp { if (Accounts.main.accessKey.isNullOrEmpty) { return const Error('请退出账号后重新登录'); } - final res = await Request().post( + final res = await Request.post( Api.dislikeVideo, data: { 'aid': IdUtils.bv2av(bvid).toString(), @@ -442,7 +442,7 @@ abstract final class VideoHttp { return const Error('请退出账号后重新登录'); } assert((reasonId != null) ^ (feedbackId != null)); - final res = await Request().get( + final res = await Request.get( Api.feedDislike, queryParameters: { 'goto': goto, @@ -470,7 +470,7 @@ abstract final class VideoHttp { if (Accounts.get(AccountType.recommend).accessKey.isNullOrEmpty) { return const Error('请退出账号后重新登录'); } - final res = await Request().get( + final res = await Request.get( Api.feedDislikeCancel, queryParameters: { 'goto': goto, @@ -518,7 +518,7 @@ abstract final class VideoHttp { if (syncToDynamic) 'sync_to_dynamic': 1, 'csrf': Accounts.main.csrf, }; - final res = await Request().post( + final res = await Request.post( Api.replyAdd, data: data, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -541,7 +541,7 @@ abstract final class VideoHttp { required int oid, required int rpid, }) async { - final res = await Request().post( + final res = await Request.post( Api.replyDel, data: { 'type': type, //type.index @@ -564,7 +564,7 @@ abstract final class VideoHttp { required int act, required int reSrc, }) async { - final res = await Request().post( + final res = await Request.post( Api.relationMod, queryParameters: { 'statistics': '{"appId":100,"platform":5}', @@ -608,7 +608,7 @@ abstract final class VideoHttp { } static Future roomEntryAction({required Object roomId}) { - return Request().post( + return Request.post( Api.roomEntryAction, queryParameters: {'csrf': Accounts.heartbeat.csrf}, data: {'room_id': roomId, 'platform': 'pc'}, @@ -619,7 +619,7 @@ abstract final class VideoHttp { required Object aid, required Object type, }) { - return Request().post( + return Request.post( Api.historyReport, data: {'aid': aid, 'type': type, 'csrf': Accounts.heartbeat.csrf}, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -638,7 +638,7 @@ abstract final class VideoHttp { required VideoType videoType, }) { final isPugv = videoType == VideoType.pugv; - return Request().post( + return Request.post( Api.heartBeat, data: { if (isPugv) 'aid': ?aid else 'bvid': ?bvid, @@ -659,7 +659,7 @@ abstract final class VideoHttp { required Object oid, required Object upperMid, }) { - return Request().post( + return Request.post( Api.mediaListHistory, data: { 'desc': desc, @@ -673,7 +673,7 @@ abstract final class VideoHttp { // 添加追番 static Future> pgcAdd({int? seasonId}) async { - final res = await Request().post( + final res = await Request.post( Api.pgcAdd, data: {'season_id': seasonId, 'csrf': Accounts.main.csrf}, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -687,7 +687,7 @@ abstract final class VideoHttp { // 取消追番 static Future> pgcDel({int? seasonId}) async { - final res = await Request().post( + final res = await Request.post( Api.pgcDel, data: {'season_id': seasonId, 'csrf': Accounts.main.csrf}, options: Options(contentType: Headers.formUrlEncodedContentType), @@ -703,7 +703,7 @@ abstract final class VideoHttp { required String seasonId, required int status, }) async { - final res = await Request().post( + final res = await Request.post( Api.pgcUpdate, data: { 'season_id': seasonId, @@ -726,7 +726,7 @@ abstract final class VideoHttp { required int cid, }) async { assert(aid != null || bvid != null); - final res = await Request().get( + final res = await Request.get( Api.onlineTotal, queryParameters: {'aid': aid, 'bvid': bvid, 'cid': cid}, ); @@ -747,7 +747,7 @@ abstract final class VideoHttp { 'cid': cid, 'up_mid': ?upMid, }); - final res = await Request().get(Api.aiConclusion, queryParameters: params); + final res = await Request.get(Api.aiConclusion, queryParameters: params); final int? code = res.data['code']; if (code == 0) { final int? dataCode = res.data['data']?['code']; @@ -769,7 +769,7 @@ abstract final class VideoHttp { dynamic epId, }) async { assert(aid != null || bvid != null); - final res = await Request().get( + final res = await Request.get( Api.playInfo, queryParameters: await WbiSign.makSign({ 'aid': ?aid, @@ -810,7 +810,7 @@ abstract final class VideoHttp { } static Future vttSubtitles(String subtitleUrl) async { - final res = await Request().get("https:$subtitleUrl"); + final res = await Request.get("https:$subtitleUrl"); if (res.data?['body'] case List list) { return compute(processList, list); } @@ -821,7 +821,7 @@ abstract final class VideoHttp { static Future>> getRankVideoList( int rid, ) async { - final res = await Request().get( + final res = await Request.get( Api.getRankApi, queryParameters: await WbiSign.makSign({'rid': rid, 'type': 'all'}), ); @@ -841,7 +841,7 @@ abstract final class VideoHttp { int day = 3, required int seasonType, }) async { - final res = await Request().get( + final res = await Request.get( Api.pgcRank, queryParameters: await WbiSign.makSign({ 'day': day, @@ -864,7 +864,7 @@ abstract final class VideoHttp { int day = 3, required int seasonType, }) async { - final res = await Request().get( + final res = await Request.get( Api.pgcSeasonRank, queryParameters: await WbiSign.makSign({ 'day': day, @@ -887,7 +887,7 @@ abstract final class VideoHttp { dynamic uperMid, required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.archiveNoteList, queryParameters: { 'csrf': Accounts.main.csrf, @@ -907,7 +907,7 @@ abstract final class VideoHttp { static Future?>> popularSeriesList() async { - final res = await Request().get( + final res = await Request.get( Api.popularSeriesList, queryParameters: await WbiSign.makSign({'web_location': 333.934}), ); @@ -927,7 +927,7 @@ abstract final class VideoHttp { static Future> popularSeriesOne({ required int number, }) async { - final res = await Request().get( + final res = await Request.get( Api.popularSeriesOne, queryParameters: await WbiSign.makSign({ 'number': number, @@ -944,7 +944,7 @@ abstract final class VideoHttp { static Future> popularPrecious({ required int page, }) async { - final res = await Request().get( + final res = await Request.get( Api.popularPrecious, queryParameters: await WbiSign.makSign({ 'page_size': 100, @@ -981,7 +981,7 @@ abstract final class VideoHttp { 'qn': qn ?? 80, }; AppSign.appSign(params); - final res = await Request().get(Api.tvPlayUrl, queryParameters: params); + final res = await Request.get(Api.tvPlayUrl, queryParameters: params); if (res.data['code'] == 0) { return Success(PlayUrlModel.fromJson(res.data['data'])); } else { @@ -993,7 +993,7 @@ abstract final class VideoHttp { required String bvid, required int cid, }) async { - final res = await Request().get( + final res = await Request.get( Api.videoshot, queryParameters: { // 'aid': IdUtils.bv2av(_bvid), diff --git a/lib/main.dart b/lib/main.dart index 15ef11148..46519c253 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -123,7 +123,7 @@ void main() async { await setupServiceLocator(); } - Request(); + Request.init(); Request.setCookie(); RequestUtils.syncHistoryStatus(); diff --git a/lib/pages/audio/controller.dart b/lib/pages/audio/controller.dart index 0d11ae1cb..6f4f12972 100644 --- a/lib/pages/audio/controller.dart +++ b/lib/pages/audio/controller.dart @@ -443,7 +443,7 @@ class AudioController extends GetxController hasLike.value = true; if (response.coinOk && !hasCoin) { coinNum.value = 2; - GlobalData().afterCoin(2); + GlobalData.afterCoin(2); try { audioItem.value!.stat ..hasCoin_8 = true @@ -479,7 +479,7 @@ class AudioController extends GetxController return; } - if (GlobalData().coins != null && GlobalData().coins! < 1) { + if (GlobalData.coins != null && GlobalData.coins! < 1) { SmartDialog.showToast('硬币不足'); // return; } @@ -516,7 +516,7 @@ class AudioController extends GetxController } audioItem.refresh(); } catch (_) {} - GlobalData().afterCoin(coin); + GlobalData.afterCoin(coin); } else { res.toast(); } diff --git a/lib/pages/blacklist/view.dart b/lib/pages/blacklist/view.dart index 5c1fea775..433120caa 100644 --- a/lib/pages/blacklist/view.dart +++ b/lib/pages/blacklist/view.dart @@ -27,7 +27,7 @@ class _BlackListPageState extends State { void dispose() { if (_blackListController.loadingState.value case Success(:final response)) { final blackMids = response?.map((e) => e.mid!).toSet() ?? {}; - GlobalData().blackMids = blackMids; + GlobalData.blackMids = blackMids; Pref.blackMids = blackMids; } super.dispose(); diff --git a/lib/pages/common/common_intro_controller.dart b/lib/pages/common/common_intro_controller.dart index 45d5ffec5..8373459ce 100644 --- a/lib/pages/common/common_intro_controller.dart +++ b/lib/pages/common/common_intro_controller.dart @@ -132,7 +132,7 @@ abstract class CommonIntroController extends GetxController if (res.isSuccess) { SmartDialog.showToast('投币成功'); coinNum.value += coin; - GlobalData().afterCoin(coin); + GlobalData.afterCoin(coin); stat.coin += coin; if (selectLike && !hasLike.value) { stat.like++; diff --git a/lib/pages/dynamics_tab/view.dart b/lib/pages/dynamics_tab/view.dart index c14c2e08b..8cbb98646 100644 --- a/lib/pages/dynamics_tab/view.dart +++ b/lib/pages/dynamics_tab/view.dart @@ -90,7 +90,7 @@ class _DynamicsTabPageState extends State Loading() => dynSkeleton, Success(:final response) => response != null && response.isNotEmpty - ? GlobalData().dynamicsWaterfallFlow + ? GlobalData.dynamicsWaterfallFlow ? SliverWaterfallFlow( gridDelegate: dynGridDelegate, delegate: SliverChildBuilderDelegate( diff --git a/lib/pages/dynamics_topic/view.dart b/lib/pages/dynamics_topic/view.dart index 9ca032ff9..654c47df1 100644 --- a/lib/pages/dynamics_topic/view.dart +++ b/lib/pages/dynamics_topic/view.dart @@ -347,7 +347,7 @@ class _DynTopicPageState extends State with DynMixin { Loading() => dynSkeleton, Success(:final response) => response != null && response.isNotEmpty - ? GlobalData().dynamicsWaterfallFlow + ? GlobalData.dynamicsWaterfallFlow ? SliverWaterfallFlow( gridDelegate: dynGridDelegate, delegate: SliverChildBuilderDelegate( diff --git a/lib/pages/login/controller.dart b/lib/pages/login/controller.dart index 072770cbd..b935d7a92 100644 --- a/lib/pages/login/controller.dart +++ b/lib/pages/login/controller.dart @@ -137,7 +137,7 @@ class LoginPageController extends GetxController return; } try { - final result = await Request().get( + final result = await Request.get( "/x/member/web/account", options: Options( headers: { diff --git a/lib/pages/login/geetest/geetest_webview_dialog.dart b/lib/pages/login/geetest/geetest_webview_dialog.dart index f0b735022..1d165385f 100644 --- a/lib/pages/login/geetest/geetest_webview_dialog.dart +++ b/lib/pages/login/geetest/geetest_webview_dialog.dart @@ -22,7 +22,7 @@ class GeetestWebviewDialog extends StatelessWidget { String gt, String challenge, ) async { - final res = await Request().get( + final res = await Request.get( 'https://api.geetest.com/gettype.php', queryParameters: {'gt': gt}, options: Options( diff --git a/lib/pages/member_dynamics/view.dart b/lib/pages/member_dynamics/view.dart index 1a5e09538..d8c6dd21d 100644 --- a/lib/pages/member_dynamics/view.dart +++ b/lib/pages/member_dynamics/view.dart @@ -81,7 +81,7 @@ class _MemberDynamicsPageState extends State Loading() => dynSkeleton, Success(:final response) => response != null && response.isNotEmpty - ? GlobalData().dynamicsWaterfallFlow + ? GlobalData.dynamicsWaterfallFlow ? SliverWaterfallFlow( gridDelegate: dynGridDelegate, delegate: SliverChildBuilderDelegate( diff --git a/lib/pages/member_favorite/controller.dart b/lib/pages/member_favorite/controller.dart index cd5add940..cb44707b2 100644 --- a/lib/pages/member_favorite/controller.dart +++ b/lib/pages/member_favorite/controller.dart @@ -81,7 +81,7 @@ class MemberFavoriteCtr Future userFavFolder() async { try { - final res = await Request().get( + final res = await Request.get( Api.userFavFolder, queryParameters: { 'pn': favPage, @@ -117,7 +117,7 @@ class MemberFavoriteCtr Future userSubFolder() async { try { - final res = await Request().get( + final res = await Request.get( Api.userSubFolder, queryParameters: { 'up_mid': mid, diff --git a/lib/pages/member_profile/view.dart b/lib/pages/member_profile/view.dart index 88967bf30..4471093a2 100644 --- a/lib/pages/member_profile/view.dart +++ b/lib/pages/member_profile/view.dart @@ -78,38 +78,36 @@ class _EditProfilePageState extends State { 's_locale': 'zh_CN', 'statistics': Constants.statistics, }; - Request() - .get( - '${HttpString.appBaseUrl}/x/v2/account/myinfo', - queryParameters: data, - ) - .then((res) { - if (mounted) { - setState(() { - if (res.data['code'] == 0) { - AccountMyInfoData data = AccountMyInfoData.fromJson( - res.data['data'], - ); - _loadingState = Success(data); - accountService.face.value = data.face!; - try { - UserInfoData userInfo = Pref.userInfoCache! - ..uname = data.name - ..face = data.face; - GStorage.userInfo.put('userInfoCache', userInfo); - } catch (_) {} - try { - Get.find().userInfo - ..value.uname = data.name - ..value.face = data.face - ..refresh(); - } catch (_) {} - } else { - _loadingState = Error(res.data['message']); - } - }); + Request.get( + '${HttpString.appBaseUrl}/x/v2/account/myinfo', + queryParameters: data, + ).then((res) { + if (mounted) { + setState(() { + if (res.data['code'] == 0) { + AccountMyInfoData data = AccountMyInfoData.fromJson( + res.data['data'], + ); + _loadingState = Success(data); + accountService.face.value = data.face!; + try { + UserInfoData userInfo = Pref.userInfoCache! + ..uname = data.name + ..face = data.face; + GStorage.userInfo.put('userInfoCache', userInfo); + } catch (_) {} + try { + Get.find().userInfo + ..value.uname = data.name + ..value.face = data.face + ..refresh(); + } catch (_) {} + } else { + _loadingState = Error(res.data['message']); } }); + } + }); } Widget _buildBody( @@ -371,49 +369,47 @@ class _EditProfilePageState extends State { 'sex': datum.toString(), }; AppSign.appSign(data); - Request() - .post( - '/x/member/app/${type.name}/update', - data: data, - options: Options( - contentType: Headers.formUrlEncodedContentType, - ), - ) - .then((res) { - if (res.data['code'] == 0) { - AccountMyInfoData data = _loadingState.data; - if (type == ProfileType.uname) { - data - ..name = _textController.text - ..coins = data.coins! - 6; - try { - UserInfoData userInfo = Pref.userInfoCache! - ..uname = _textController.text; - GStorage.userInfo.put('userInfoCache', userInfo); - } catch (_) {} - try { - Get.find().userInfo - ..value.uname = _textController.text - ..refresh(); - } catch (_) {} - } else if (type == ProfileType.sign) { - data.sign = _textController.text; - } else if (type == ProfileType.birthday) { - data.birthday = datum; - } else if (type == ProfileType.sex) { - data.sex = datum; - } - SmartDialog.showToast('修改成功'); - if (mounted) { - setState(() {}); - } - if (type == ProfileType.uname || type == ProfileType.sign) { - Get.back(); - } - } else { - SmartDialog.showToast(res.data['message']); - } - }); + Request.post( + '/x/member/app/${type.name}/update', + data: data, + options: Options( + contentType: Headers.formUrlEncodedContentType, + ), + ).then((res) { + if (res.data['code'] == 0) { + AccountMyInfoData data = _loadingState.data; + if (type == ProfileType.uname) { + data + ..name = _textController.text + ..coins = data.coins! - 6; + try { + UserInfoData userInfo = Pref.userInfoCache! + ..uname = _textController.text; + GStorage.userInfo.put('userInfoCache', userInfo); + } catch (_) {} + try { + Get.find().userInfo + ..value.uname = _textController.text + ..refresh(); + } catch (_) {} + } else if (type == ProfileType.sign) { + data.sign = _textController.text; + } else if (type == ProfileType.birthday) { + data.birthday = datum; + } else if (type == ProfileType.sex) { + data.sex = datum; + } + SmartDialog.showToast('修改成功'); + if (mounted) { + setState(() {}); + } + if (type == ProfileType.uname || type == ProfileType.sign) { + Get.back(); + } + } else { + SmartDialog.showToast(res.data['message']); + } + }); } String _sex(int sex) { @@ -517,33 +513,31 @@ class _EditProfilePageState extends State { imagePath = croppedFile?.path; } if (imagePath != null) { - Request() - .post( - '/x/member/web/face/update', - queryParameters: { - 'csrf': Accounts.main.csrf, - }, - data: FormData.fromMap({ - 'dopost': 'save', - 'DisplayRank': 10000, - 'face': await MultipartFile.fromFile(imagePath), - }), - ) - .then((res) { - if (res.data['code'] == 0) { - SmartDialog.showToast('修改成功'); - Future.delayed(const Duration(milliseconds: 500), () { - if (mounted) { - _getInfo(); - } - }); - } else { - SmartDialog.showToast(res.data['message']); - } - if (PlatformUtils.isMobile && imagePath != null) { - File(imagePath).tryDel(); + Request.post( + '/x/member/web/face/update', + queryParameters: { + 'csrf': Accounts.main.csrf, + }, + data: FormData.fromMap({ + 'dopost': 'save', + 'DisplayRank': 10000, + 'face': await MultipartFile.fromFile(imagePath), + }), + ).then((res) { + if (res.data['code'] == 0) { + SmartDialog.showToast('修改成功'); + Future.delayed(const Duration(milliseconds: 500), () { + if (mounted) { + _getInfo(); } }); + } else { + SmartDialog.showToast(res.data['message']); + } + if (PlatformUtils.isMobile && imagePath != null) { + File(imagePath).tryDel(); + } + }); } } } catch (e) { diff --git a/lib/pages/member_search/child/view.dart b/lib/pages/member_search/child/view.dart index ec4259884..dda42631f 100644 --- a/lib/pages/member_search/child/view.dart +++ b/lib/pages/member_search/child/view.dart @@ -83,7 +83,7 @@ class _MemberSearchChildPageState extends State itemCount: response.length, ), MemberSearchType.dynamic => - GlobalData().dynamicsWaterfallFlow + GlobalData.dynamicsWaterfallFlow ? SliverWaterfallFlow( gridDelegate: dynGridDelegate, delegate: SliverChildBuilderDelegate( diff --git a/lib/pages/setting/models/style_settings.dart b/lib/pages/setting/models/style_settings.dart index 371299416..3d210ea0d 100644 --- a/lib/pages/setting/models/style_settings.dart +++ b/lib/pages/setting/models/style_settings.dart @@ -101,7 +101,7 @@ List get styleSettings => [ title: '图片质量', initValue: Pref.picQuality, onChanged: (picQuality) async { - GlobalData().imgQuality = picQuality; + GlobalData.imgQuality = picQuality; await GStorage.setting.put(SettingBoxKey.defaultPicQa, picQuality); setState(); }, diff --git a/lib/pages/video/controller.dart b/lib/pages/video/controller.dart index 96caf3599..1bf79915a 100644 --- a/lib/pages/video/controller.dart +++ b/lib/pages/video/controller.dart @@ -1049,7 +1049,7 @@ class VideoDetailController extends GetxController Future getSteinEdgeInfo([int? edgeId]) async { steinEdgeInfo = null; try { - final res = await Request().get( + final res = await Request.get( '/x/stein/edgeinfo_v2', queryParameters: { 'bvid': bvid, diff --git a/lib/pages/video/introduction/pgc/controller.dart b/lib/pages/video/introduction/pgc/controller.dart index 15138bb9b..e6b8e471d 100644 --- a/lib/pages/video/introduction/pgc/controller.dart +++ b/lib/pages/video/introduction/pgc/controller.dart @@ -126,7 +126,7 @@ class PgcIntroController extends CommonIntroController { return; } - if (GlobalData().coins != null && GlobalData().coins! < 1) { + if (GlobalData.coins != null && GlobalData.coins! < 1) { SmartDialog.showToast('硬币不足'); // return; } @@ -435,7 +435,7 @@ class PgcIntroController extends CommonIntroController { if (response.coin == 1 && !hasCoin) { stat?.coin += 2; coinNum.value = 2; - GlobalData().afterCoin(2); + GlobalData.afterCoin(2); } if (response.favorite == 1 && !hasFav.value) { stat?.favorite++; diff --git a/lib/pages/video/introduction/ugc/controller.dart b/lib/pages/video/introduction/ugc/controller.dart index 3947e6f1b..eb1257e1a 100644 --- a/lib/pages/video/introduction/ugc/controller.dart +++ b/lib/pages/video/introduction/ugc/controller.dart @@ -132,7 +132,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { // 获取up主粉丝数 Future queryUserStat(List? staff) async { if (staff != null && staff.isNotEmpty) { - final res = await Request().get( + final res = await Request.get( Api.relations, queryParameters: {'fids': staff.map((item) => item.mid).join(',')}, ); @@ -190,7 +190,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { if (response.coin == true && !hasCoin) { stat?.coin += 2; coinNum.value = 2; - GlobalData().afterCoin(2); + GlobalData.afterCoin(2); } if (response.fav == true && !hasFav.value) { stat?.favorite++; @@ -271,7 +271,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { return; } - if (GlobalData().coins != null && GlobalData().coins! < 1) { + if (GlobalData.coins != null && GlobalData.coins! < 1) { SmartDialog.showToast('硬币不足'); // return; } diff --git a/lib/pages/video/pay_coins/view.dart b/lib/pages/video/pay_coins/view.dart index 0ed9aaeef..9f93d44ee 100644 --- a/lib/pages/video/pay_coins/view.dart +++ b/lib/pages/video/pay_coins/view.dart @@ -86,7 +86,7 @@ class _PayCoinsPageState extends State _timer = null; } - final num? _coins = GlobalData().coins; + final num? _coins = GlobalData.coins; bool _canPay(int index) { if (index == 1 && widget.hasCoin) { diff --git a/lib/utils/global_data.dart b/lib/utils/global_data.dart index d536170f6..a0e154701 100644 --- a/lib/utils/global_data.dart +++ b/lib/utils/global_data.dart @@ -1,26 +1,17 @@ import 'package:PiliPlus/utils/storage_pref.dart'; -class GlobalData { - int imgQuality = Pref.picQuality; +abstract final class GlobalData { + static int imgQuality = Pref.picQuality; - num? coins; + static num? coins; - void afterCoin(num coin) { + static void afterCoin(num coin) { if (coins != null) { coins = coins! - coin; } } - Set blackMids = Pref.blackMids; + static Set blackMids = Pref.blackMids; - bool dynamicsWaterfallFlow = Pref.dynamicsWaterfallFlow; - - // 私有构造函数 - GlobalData._(); - - // 单例实例 - static final GlobalData _instance = GlobalData._(); - - // 获取全局实例 - factory GlobalData() => _instance; + static bool dynamicsWaterfallFlow = Pref.dynamicsWaterfallFlow; } diff --git a/lib/utils/image_utils.dart b/lib/utils/image_utils.dart index 9f4aac28e..282ff82ac 100644 --- a/lib/utils/image_utils.dart +++ b/lib/utils/image_utils.dart @@ -33,7 +33,7 @@ abstract final class ImageUtils { try { SmartDialog.showLoading(); final path = '$tmpDirPath/${Utils.getFileName(url)}'; - final res = await Request().downloadFile(url.http2https, path); + final res = await Request.downloadFile(url.http2https, path); SmartDialog.dismiss(); if (res.statusCode == 200) { await SharePlus.instance @@ -106,11 +106,11 @@ abstract final class ImageUtils { String videoName = "video_${Utils.getFileName(liveUrl)}"; String videoPath = '$tmpDirPath/$videoName'; - final res = await Request().downloadFile(liveUrl.http2https, videoPath); + final res = await Request.downloadFile(liveUrl.http2https, videoPath); if (res.statusCode != 200) throw '${res.statusCode}'; if (Platform.isIOS) { - final res1 = await Request().downloadFile(url.http2https, imagePath); + final res1 = await Request.downloadFile(url.http2https, imagePath); if (res1.statusCode != 200) throw '${res1.statusCode}'; SmartDialog.showLoading(msg: '正在保存'); bool success = @@ -174,7 +174,7 @@ abstract final class ImageUtils { if (file == null) { final String filePath = '$tmpDirPath/$name'; - final response = await Request().downloadFile( + final response = await Request.downloadFile( url.http2https, filePath, cancelToken: cancelToken, @@ -275,7 +275,7 @@ abstract final class ImageUtils { String suffix = kSuffixWEBP, }) { if (src != null && maxQuality != 100) { - maxQuality = math.max(maxQuality, GlobalData().imgQuality); + maxQuality = math.max(maxQuality, GlobalData.imgQuality); bool hasMatch = false; src = src.splitMapJoin( _thumbRegex, diff --git a/lib/utils/page_utils.dart b/lib/utils/page_utils.dart index abb4c75c9..0f4cd5d02 100644 --- a/lib/utils/page_utils.dart +++ b/lib/utils/page_utils.dart @@ -53,7 +53,7 @@ abstract final class PageUtils { pageBuilder: (context, animation, secondaryAnimation) => GalleryViewer( sources: imgList, initIndex: initialPage, - quality: quality ?? GlobalData().imgQuality, + quality: quality ?? GlobalData.imgQuality, onPageChanged: onPageChanged, tag: tag, ), @@ -399,7 +399,7 @@ abstract final class PageUtils { (context) => GalleryViewer( sources: imgList, initIndex: index, - quality: GlobalData().imgQuality, + quality: GlobalData.imgQuality, ), enableDrag: false, elevation: 0.0, diff --git a/lib/utils/storage_pref.dart b/lib/utils/storage_pref.dart index 1df6289ab..14b7ad2ca 100644 --- a/lib/utils/storage_pref.dart +++ b/lib/utils/storage_pref.dart @@ -62,12 +62,12 @@ abstract final class Pref { static void setBlackMid(int mid) => _localCache.put( LocalCacheKey.blackMids, - GlobalData().blackMids..add(mid), + GlobalData.blackMids..add(mid), ); static void removeBlackMid(int mid) => _localCache.put( LocalCacheKey.blackMids, - GlobalData().blackMids..remove(mid), + GlobalData.blackMids..remove(mid), ); static int get _themeTypeInt => _setting.get( diff --git a/lib/utils/waterfall.dart b/lib/utils/waterfall.dart index 55fde4762..a13e4b086 100644 --- a/lib/utils/waterfall.dart +++ b/lib/utils/waterfall.dart @@ -16,7 +16,7 @@ mixin DynMixin { ); Widget buildPage(Widget child) { - if (GlobalData().dynamicsWaterfallFlow) { + if (GlobalData.dynamicsWaterfallFlow) { return child; } return SliverLayoutBuilder( @@ -43,7 +43,7 @@ mixin DynMixin { ); Widget get dynSkeleton { - if (GlobalData().dynamicsWaterfallFlow) { + if (GlobalData.dynamicsWaterfallFlow) { return SliverGrid.builder( gridDelegate: skeDelegate, itemBuilder: (_, _) => const DynamicCardSkeleton(), diff --git a/lib/utils/wbi_sign.dart b/lib/utils/wbi_sign.dart index a67719619..435be50ac 100644 --- a/lib/utils/wbi_sign.dart +++ b/lib/utils/wbi_sign.dart @@ -76,7 +76,7 @@ abstract final class WbiSign { } static Future _getWbiKeys() async { - final resp = await Request().get(Api.userInfo); + final resp = await Request.get(Api.userInfo); try { final wbiUrls = resp.data['data']['wbi_img'];