diff --git a/lib/http/black.dart b/lib/http/black.dart index 9c5f14e9b..766b0b8de 100644 --- a/lib/http/black.dart +++ b/lib/http/black.dart @@ -7,13 +7,13 @@ import 'package:PiliPlus/utils/accounts.dart'; class BlackHttp { static Future> blackList({ required int pn, - int? ps, + int ps = 50, }) async { var res = await Request().get( Api.blackLst, queryParameters: { 'pn': pn, - 'ps': ps ?? 50, + 'ps': ps, 're_version': 0, 'jsonp': 'jsonp', 'csrf': Accounts.main.csrf, diff --git a/lib/http/fan.dart b/lib/http/fan.dart index 91c2ee4bc..3df1a5d80 100644 --- a/lib/http/fan.dart +++ b/lib/http/fan.dart @@ -7,7 +7,7 @@ class FanHttp { static Future> fans({ int? vmid, int? pn, - int? ps, + int ps = 20, String? orderType, }) async { var res = await Request().get( diff --git a/lib/http/follow.dart b/lib/http/follow.dart index 0b3e7f364..5c8779267 100644 --- a/lib/http/follow.dart +++ b/lib/http/follow.dart @@ -7,7 +7,7 @@ class FollowHttp { static Future> followings({ int? vmid, int? pn, - int? ps, + int ps = 50, String orderType = '', }) async { var res = await Request().get( @@ -32,7 +32,7 @@ class FollowHttp { static Future> followingsNew({ int? vmid, int? pn, - int? ps, + int ps = 20, String orderType = '', // ''=>最近关注,'attention'=>最常访问 }) async { var res = await Request().get( diff --git a/lib/http/init.dart b/lib/http/init.dart index 2c2660723..39ca623dd 100644 --- a/lib/http/init.dart +++ b/lib/http/init.dart @@ -280,16 +280,6 @@ class Request { } } - /* - * 取消请求 - * - * 同一个cancel token 可以用于多个请求,当一个cancel token取消时,所有使用该cancel token的请求都会被取消。 - * 所以参数可选 - */ - void cancelRequests(CancelToken token) { - token.cancel("cancelled"); - } - static String responseDecoder( List responseBytes, RequestOptions options, diff --git a/lib/http/member.dart b/lib/http/member.dart index fa4f07590..a432f4b0f 100644 --- a/lib/http/member.dart +++ b/lib/http/member.dart @@ -526,12 +526,12 @@ class MemberHttp { } // 获取某分组下的up - static Future> followUpGroup( + static Future> followUpGroup({ int? mid, int? tagid, int? pn, - int? ps, - ) async { + int ps = 20, + }) async { var res = await Request().get( Api.followUpGroup, queryParameters: { diff --git a/lib/http/video.dart b/lib/http/video.dart index 232af082b..4db0e98a8 100644 --- a/lib/http/video.dart +++ b/lib/http/video.dart @@ -816,7 +816,7 @@ class VideoHttp { } } - static Future vttSubtitles(String subtitleUrl) async { + static Future vttSubtitles(String subtitleUrl) async { String subtitleTimecode(num seconds) { int h = seconds ~/ 3600; seconds %= 3600; @@ -842,8 +842,8 @@ class VideoHttp { var res = await Request().get("https:$subtitleUrl"); - if (res.data?['body'] is List) { - return await compute(processList, res.data['body'] as List); + if (res.data?['body'] case List list) { + return compute(processList, list); } return null; } diff --git a/lib/models_new/article/article_view/opus.dart b/lib/models_new/article/article_view/opus.dart index 67c62f52d..cc1cbaf56 100644 --- a/lib/models_new/article/article_view/opus.dart +++ b/lib/models_new/article/article_view/opus.dart @@ -10,10 +10,8 @@ class ArticleOpus { opusid = json['opus_id']; opussource = json['opus_source']; title = json['title']; - if (json['content']?['paragraphs'] is List) { - content = (json['content']['paragraphs'] as List) - .map((i) => ArticleContentModel.fromJson(i)) - .toList(); + if (json['content']?['paragraphs'] case List list) { + content = list.map((i) => ArticleContentModel.fromJson(i)).toList(); } } } diff --git a/lib/pages/blacklist/controller.dart b/lib/pages/blacklist/controller.dart index 1b962df93..17e2324d9 100644 --- a/lib/pages/blacklist/controller.dart +++ b/lib/pages/blacklist/controller.dart @@ -11,7 +11,6 @@ import 'package:get/get.dart'; class BlackListController extends CommonListController { - int pageSize = 50; RxInt total = (-1).obs; @override @@ -52,5 +51,5 @@ class BlackListController @override Future> customGetData() => - BlackHttp.blackList(pn: page, ps: pageSize); + BlackHttp.blackList(pn: page); } diff --git a/lib/pages/dynamics/controller.dart b/lib/pages/dynamics/controller.dart index 0dc2bae2a..60fd6c405 100644 --- a/lib/pages/dynamics/controller.dart +++ b/lib/pages/dynamics/controller.dart @@ -67,7 +67,6 @@ class DynamicsController extends GetxController var res = await FollowHttp.followings( vmid: accountService.mid, pn: allFollowedUpsPage, - ps: 50, orderType: 'attention', ); if (res.isSuccess) { @@ -108,7 +107,6 @@ class DynamicsController extends GetxController final f2 = FollowHttp.followings( vmid: accountService.mid, pn: allFollowedUpsPage, - ps: 50, orderType: 'attention', ); final res0 = await f1; diff --git a/lib/pages/fan/controller.dart b/lib/pages/fan/controller.dart index 8052da531..ca9970781 100644 --- a/lib/pages/fan/controller.dart +++ b/lib/pages/fan/controller.dart @@ -8,7 +8,6 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; class FansController extends CommonListController { FansController(this.mid); - int ps = 20; int total = 0; int mid; @@ -27,7 +26,6 @@ class FansController extends CommonListController { Future> customGetData() => FanHttp.fans( vmid: mid, pn: page, - ps: ps, orderType: 'attention', ); diff --git a/lib/pages/follow/child/child_controller.dart b/lib/pages/follow/child/child_controller.dart index c2750bb29..4023a6ec0 100644 --- a/lib/pages/follow/child/child_controller.dart +++ b/lib/pages/follow/child/child_controller.dart @@ -48,13 +48,12 @@ class FollowChildController @override Future> customGetData() { if (tagid != null) { - return MemberHttp.followUpGroup(mid, tagid, page, 20); + return MemberHttp.followUpGroup(mid: mid, tagid: tagid, pn: page); } return FollowHttp.followingsNew( vmid: mid, pn: page, - ps: 20, orderType: orderType.value.type, ); } diff --git a/lib/pages/search/widgets/hot_keyword.dart b/lib/pages/search/widgets/hot_keyword.dart index bfa15d4da..66f9ac8ef 100644 --- a/lib/pages/search/widgets/hot_keyword.dart +++ b/lib/pages/search/widgets/hot_keyword.dart @@ -8,13 +8,11 @@ class HotKeyword extends StatelessWidget { final double width; final List hotSearchList; final Function? onClick; - final bool showMore; const HotKeyword({ super.key, required double width, required this.hotSearchList, this.onClick, - this.showMore = true, }) : width = width / 2 - 4; @override diff --git a/lib/pages/setting/view.dart b/lib/pages/setting/view.dart index ff86635e7..762a15264 100644 --- a/lib/pages/setting/view.dart +++ b/lib/pages/setting/view.dart @@ -42,42 +42,42 @@ class _SettingPageState extends State { final RxBool _noAccount = Accounts.accountMode.isEmpty.obs; late bool _isPortrait; - final List<_SettingsModel> _items = [ - const _SettingsModel( + final List<_SettingsModel> _items = const [ + _SettingsModel( type: SettingType.privacySetting, subtitle: '黑名单、无痕模式', icon: Icons.privacy_tip_outlined, ), - const _SettingsModel( + _SettingsModel( type: SettingType.recommendSetting, subtitle: '推荐来源(web/app)、刷新保留内容、过滤器', icon: Icons.explore_outlined, ), - const _SettingsModel( + _SettingsModel( type: SettingType.videoSetting, subtitle: '画质、音质、解码、缓冲、音频输出等', icon: Icons.video_settings_outlined, ), - const _SettingsModel( + _SettingsModel( type: SettingType.playSetting, subtitle: '双击/长按、全屏、后台播放、弹幕、字幕、底部进度条等', icon: Icons.touch_app_outlined, ), - const _SettingsModel( + _SettingsModel( type: SettingType.styleSetting, subtitle: '横屏适配(平板)、侧栏、列宽、首页、动态红点、主题、字号、图片、帧率等', icon: Icons.style_outlined, ), - const _SettingsModel( + _SettingsModel( type: SettingType.extraSetting, subtitle: '震动、搜索、收藏、ai、评论、动态、代理、更新检查等', icon: Icons.extension_outlined, ), - const _SettingsModel( + _SettingsModel( type: SettingType.webdavSetting, icon: MdiIcons.databaseCogOutline, ), - const _SettingsModel( + _SettingsModel( type: SettingType.about, icon: Icons.info_outline, ), diff --git a/lib/pages/video/controller.dart b/lib/pages/video/controller.dart index 3df1d0b8d..55c68b094 100644 --- a/lib/pages/video/controller.dart +++ b/lib/pages/video/controller.dart @@ -1435,7 +1435,7 @@ class VideoDetailController extends GetxController return; } - void setSub(subtitle) { + void setSub(String subtitle) { plPlayerController.videoPlayerController?.setSubtitleTrack( SubtitleTrack.data( subtitle, diff --git a/lib/pages/video/widgets/header_control.dart b/lib/pages/video/widgets/header_control.dart index c581e2032..01c44934e 100644 --- a/lib/pages/video/widgets/header_control.dart +++ b/lib/pages/video/widgets/header_control.dart @@ -870,19 +870,17 @@ class HeaderControlState extends State { try { final res = await Dio().get( item.subtitleUrl!.http2https, - options: Options( - responseType: ResponseType.bytes, - ), + options: Options(responseType: ResponseType.bytes), ); if (res.statusCode == 200) { final name = - '${videoIntroController.videoDetail.value.title}-${videoDetailCtr.bvid}-${videoDetailCtr.cid.value}-${item.lanDoc}'; + '${videoIntroController.videoDetail.value.title}-${videoDetailCtr.bvid}-${videoDetailCtr.cid.value}-${item.lanDoc}.json'; try { DocumentFileSavePlusPlatform.instance .saveMultipleFiles( dataList: [res.data], fileNameList: [name], - mimeTypeList: ['text/plain'], + mimeTypeList: [Headers.jsonContentType], ); if (Platform.isAndroid) { SmartDialog.showToast('已保存'); @@ -894,7 +892,7 @@ class HeaderControlState extends State { XFile.fromData( res.data, name: name, - mimeType: 'text/plain', + mimeType: Headers.jsonContentType, ), ], sharePositionOrigin: await Utils.isIpad()