diff --git a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart index 900ed4aa4..1870d63bc 100644 --- a/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart +++ b/lib/common/widgets/interactiveviewer_gallery/interactiveviewer_gallery.dart @@ -48,7 +48,7 @@ class InteractiveviewerGallery extends StatefulWidget { this.minScale = 1.0, this.onPageChanged, this.onDismissed, - this.setStatusBar, + this.setStatusBar = true, this.onClose, required this.quality, }); @@ -57,7 +57,7 @@ class InteractiveviewerGallery extends StatefulWidget { final ValueChanged? onClose; - final bool? setStatusBar; + final bool setStatusBar; /// The sources to show. final List sources; @@ -114,7 +114,7 @@ class _InteractiveviewerGalleryState extends State duration: const Duration(milliseconds: 300), )..addListener(listener); - if (widget.setStatusBar != false) { + if (widget.setStatusBar) { setStatusBar(); } @@ -148,7 +148,7 @@ class _InteractiveviewerGalleryState extends State _animationController ..removeListener(listener) ..dispose(); - if (widget.setStatusBar != false) { + if (widget.setStatusBar) { if (Platform.isIOS || Platform.isAndroid) { SystemChrome.setEnabledSystemUIMode( mode ?? SystemUiMode.edgeToEdge, diff --git a/lib/common/widgets/video_card/video_card_h.dart b/lib/common/widgets/video_card/video_card_h.dart index 1c1c1c59a..2587cbb02 100644 --- a/lib/common/widgets/video_card/video_card_h.dart +++ b/lib/common/widgets/video_card/video_card_h.dart @@ -14,7 +14,6 @@ import 'package:PiliPlus/models/search/result.dart'; import 'package:PiliPlus/utils/date_util.dart'; import 'package:PiliPlus/utils/duration_util.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; @@ -106,11 +105,10 @@ class VideoCardH extends StatelessWidget { ); if (cid != null) { PageUtils.toVideoPage( - 'bvid=${videoItem.bvid}&cid=$cid', - arguments: { - 'videoItem': videoItem, - 'heroTag': Utils.makeHeroTag(videoItem.aid), - }, + bvid: videoItem.bvid, + cid: cid, + cover: videoItem.cover, + title: videoItem.title, ); } } catch (err) { diff --git a/lib/common/widgets/video_card/video_card_v.dart b/lib/common/widgets/video_card/video_card_v.dart index ff836214a..843703df8 100644 --- a/lib/common/widgets/video_card/video_card_v.dart +++ b/lib/common/widgets/video_card/video_card_v.dart @@ -42,11 +42,11 @@ class VideoCardV extends StatelessWidget { await SearchHttp.ab2c(aid: videoItem.aid, bvid: bvid); if (cid != null) { PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'heroTag': heroTag, - 'videoItem': videoItem, - }, + aid: videoItem.aid, + bvid: bvid, + cid: cid, + cover: videoItem.cover, + title: videoItem.title, ); } break; diff --git a/lib/pages/about/view.dart b/lib/pages/about/view.dart index 1519d9709..80c21f816 100644 --- a/lib/pages/about/view.dart +++ b/lib/pages/about/view.dart @@ -276,7 +276,7 @@ Commit Hash: ${BuildConfig.commitHash}''', ); Accounts.account .putAll(res) - .whenComplete(() => Accounts.refresh()) + .whenComplete(Accounts.refresh) .whenComplete(() { MineController.anonymity.value = !Accounts.get( diff --git a/lib/pages/common/common_intro_controller.dart b/lib/pages/common/common_intro_controller.dart index 53ef8501b..140789a94 100644 --- a/lib/pages/common/common_intro_controller.dart +++ b/lib/pages/common/common_intro_controller.dart @@ -21,9 +21,8 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; abstract class CommonIntroController extends GetxController { - String heroTag = Get.arguments['heroTag']; - - String bvid = Get.parameters['bvid']!; + late final String heroTag; + late String bvid; // 是否点赞 final RxBool hasLike = false.obs; @@ -59,11 +58,16 @@ abstract class CommonIntroController extends GetxController { late final RxString total = '1'.obs; Timer? timer; - final RxInt cid = int.parse(Get.parameters['cid']!).obs; + late final RxInt cid; @override void onInit() { super.onInit(); + final args = Get.arguments; + heroTag = args['heroTag']; + bvid = args['bvid']; + cid = RxInt(args['cid']); + queryVideoIntro(); startTimer(); } diff --git a/lib/pages/dynamics/widgets/rich_node_panel.dart b/lib/pages/dynamics/widgets/rich_node_panel.dart index c527f4710..2e7f42b46 100644 --- a/lib/pages/dynamics/widgets/rich_node_panel.dart +++ b/lib/pages/dynamics/widgets/rich_node_panel.dart @@ -12,7 +12,6 @@ import 'package:PiliPlus/pages/dynamics/widgets/vote.dart'; import 'package:PiliPlus/utils/app_scheme.dart'; import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; @@ -231,10 +230,8 @@ TextSpan? richNode( int? cid = await SearchHttp.ab2c(bvid: i.rid); if (cid != null) { PageUtils.toVideoPage( - 'bvid=${i.rid}&cid=$cid', - arguments: { - 'heroTag': Utils.makeHeroTag(i.rid), - }, + bvid: i.rid, + cid: cid, ); } } catch (err) { diff --git a/lib/pages/fav_detail/controller.dart b/lib/pages/fav_detail/controller.dart index 0bee7a9b6..7a325ea8c 100644 --- a/lib/pages/fav_detail/controller.dart +++ b/lib/pages/fav_detail/controller.dart @@ -11,7 +11,6 @@ import 'package:PiliPlus/pages/fav_sort/view.dart'; import 'package:PiliPlus/services/account_service.dart'; import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; @@ -129,10 +128,11 @@ class FavDetailController } final folderInfo = this.folderInfo.value; PageUtils.toVideoPage( - 'bvid=${element.bvid}&cid=${element.ugc!.firstCid}', - arguments: { - 'videoItem': element, - 'heroTag': Utils.makeHeroTag(element.bvid), + bvid: element.bvid, + cid: element.ugc!.firstCid!, + cover: element.cover, + title: element.title, + extraArguments: { 'sourceType': SourceType.fav, 'mediaId': folderInfo.id, 'oid': element.id, diff --git a/lib/pages/fav_detail/view.dart b/lib/pages/fav_detail/view.dart index 507e00066..70756d0c9 100644 --- a/lib/pages/fav_detail/view.dart +++ b/lib/pages/fav_detail/view.dart @@ -504,10 +504,11 @@ class _FavDetailPageState extends State { final folderInfo = _favDetailController.folderInfo.value; PageUtils.toVideoPage( - 'bvid=${item.bvid}&cid=${item.ugc?.firstCid}', - arguments: { - 'videoItem': item, - 'heroTag': Utils.makeHeroTag(item.bvid), + bvid: item.bvid, + cid: item.ugc!.firstCid!, + cover: item.cover, + title: item.title, + extraArguments: { 'sourceType': SourceType.fav, 'mediaId': folderInfo.id, 'oid': item.id, diff --git a/lib/pages/fav_search/view.dart b/lib/pages/fav_search/view.dart index 7d68e662f..00658f7ae 100644 --- a/lib/pages/fav_search/view.dart +++ b/lib/pages/fav_search/view.dart @@ -77,10 +77,11 @@ class _FavSearchPageState ) : null, onViewFav: () => PageUtils.toVideoPage( - 'bvid=${item.bvid}&cid=${item.ugc?.firstCid}', - arguments: { - 'videoItem': item, - 'heroTag': Utils.makeHeroTag(item.bvid), + bvid: item.bvid, + cid: item.ugc!.firstCid!, + cover: item.cover, + title: item.title, + extraArguments: { 'sourceType': SourceType.fav, 'mediaId': controller.mediaId, 'oid': item.id, diff --git a/lib/pages/history/widgets/item.dart b/lib/pages/history/widgets/item.dart index 97b4b595b..5642ea2f1 100644 --- a/lib/pages/history/widgets/item.dart +++ b/lib/pages/history/widgets/item.dart @@ -13,7 +13,6 @@ import 'package:PiliPlus/utils/duration_util.dart'; import 'package:PiliPlus/utils/feed_back.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; @@ -81,11 +80,11 @@ class HistoryItem extends StatelessWidget { ); if (cid != null) { PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'heroTag': Utils.makeHeroTag(aid), - 'pic': item.cover, - }, + aid: aid, + bvid: bvid, + cid: cid, + cover: item.cover, + title: item.title, ); } } diff --git a/lib/pages/later/child_view.dart b/lib/pages/later/child_view.dart index 6bcbfc24b..e924c00c2 100644 --- a/lib/pages/later/child_view.dart +++ b/lib/pages/later/child_view.dart @@ -11,7 +11,6 @@ import 'package:PiliPlus/pages/later/controller.dart'; import 'package:PiliPlus/pages/later/widgets/video_card_h_later.dart'; import 'package:PiliPlus/utils/grid.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; @@ -88,11 +87,12 @@ class _LaterViewChildPageState extends State videoItem: videoItem, onViewLater: (cid) { PageUtils.toVideoPage( - 'bvid=${videoItem.bvid}&cid=$cid', - arguments: { - 'videoItem': videoItem, + bvid: videoItem.bvid, + cid: cid, + cover: videoItem.pic, + title: videoItem.title, + extraArguments: { 'oid': videoItem.aid, - 'heroTag': Utils.makeHeroTag(videoItem.bvid), 'sourceType': SourceType.watchLater, 'count': _laterController .baseCtr diff --git a/lib/pages/later/controller.dart b/lib/pages/later/controller.dart index 7dc6b8b70..6d948f55c 100644 --- a/lib/pages/later/controller.dart +++ b/lib/pages/later/controller.dart @@ -10,7 +10,6 @@ import 'package:PiliPlus/pages/later/base_controller.dart'; import 'package:PiliPlus/services/account_service.dart'; import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; @@ -165,10 +164,11 @@ class LaterController extends MultiSelectController { SmartDialog.showToast('已跳过不支持播放的视频'); } PageUtils.toVideoPage( - 'bvid=${item.bvid}&cid=${item.cid}', - arguments: { - 'videoItem': item, - 'heroTag': Utils.makeHeroTag(item.bvid), + bvid: item.bvid, + cid: item.cid!, + cover: item.pic, + title: item.title, + extraArguments: { 'sourceType': SourceType.watchLater, 'count': baseCtr.counts[LaterViewType.all], 'favTitle': '稍后再看', diff --git a/lib/pages/later_search/view.dart b/lib/pages/later_search/view.dart index 8f3edd20b..c9aabe087 100644 --- a/lib/pages/later_search/view.dart +++ b/lib/pages/later_search/view.dart @@ -70,11 +70,12 @@ class _LaterSearchPageState videoItem: item, onViewLater: (cid) { PageUtils.toVideoPage( - 'bvid=${item.bvid}&cid=$cid', - arguments: { - 'videoItem': item, + bvid: item.bvid, + cid: cid, + cover: item.pic, + title: item.title, + extraArguments: { 'oid': item.aid, - 'heroTag': Utils.makeHeroTag(item.bvid), 'sourceType': SourceType.watchLater, 'count': controller.count, 'favTitle': '稍后再看', diff --git a/lib/pages/member_coin_arc/widgets/item.dart b/lib/pages/member_coin_arc/widgets/item.dart index 047081e66..8a534eb13 100644 --- a/lib/pages/member_coin_arc/widgets/item.dart +++ b/lib/pages/member_coin_arc/widgets/item.dart @@ -10,9 +10,7 @@ import 'package:PiliPlus/models/common/stat_type.dart'; import 'package:PiliPlus/models_new/member/coin_like_arc/item.dart'; import 'package:PiliPlus/utils/date_util.dart'; import 'package:PiliPlus/utils/duration_util.dart'; -import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; class MemberCoinLikeItem extends StatelessWidget { @@ -40,11 +38,10 @@ class MemberCoinLikeItem extends StatelessWidget { int? cid = await SearchHttp.ab2c(aid: item.param); if (cid != null) { PageUtils.toVideoPage( - 'bvid=${IdUtils.av2bv(int.parse(item.param!))}&cid=$cid', - arguments: { - 'videoItem': item, - 'heroTag': Utils.makeHeroTag(item.param), - }, + aid: int.parse(item.param!), + cid: cid, + cover: item.cover, + title: item.title, ); } } diff --git a/lib/pages/member_home/widgets/video_card_v_member_home.dart b/lib/pages/member_home/widgets/video_card_v_member_home.dart index 3cc5dca52..a5f077038 100644 --- a/lib/pages/member_home/widgets/video_card_v_member_home.dart +++ b/lib/pages/member_home/widgets/video_card_v_member_home.dart @@ -9,7 +9,6 @@ import 'package:PiliPlus/utils/app_scheme.dart'; import 'package:PiliPlus/utils/duration_util.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; // 视频卡片 - 垂直布局 @@ -21,7 +20,7 @@ class VideoCardVMemberHome extends StatelessWidget { required this.videoItem, }); - Future onPushDetail(String heroTag) async { + Future onPushDetail() async { String? goto = videoItem.goto; switch (goto) { case 'bangumi': @@ -46,11 +45,10 @@ class VideoCardVMemberHome extends StatelessWidget { int? cid = videoItem.cid ?? await SearchHttp.ab2c(aid: aid, bvid: bvid); if (cid != null) { PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'pic': videoItem.cover, - 'heroTag': heroTag, - }, + bvid: bvid, + cid: cid, + cover: videoItem.cover, + title: videoItem.title, ); } break; @@ -67,7 +65,7 @@ class VideoCardVMemberHome extends StatelessWidget { return Card( clipBehavior: Clip.hardEdge, child: InkWell( - onTap: () => onPushDetail(Utils.makeHeroTag(videoItem.bvid)), + onTap: onPushDetail, onLongPress: () => imageSaveDialog( title: videoItem.title, cover: videoItem.cover, diff --git a/lib/pages/member_profile/view.dart b/lib/pages/member_profile/view.dart index 06e302dba..40dc105c4 100644 --- a/lib/pages/member_profile/view.dart +++ b/lib/pages/member_profile/view.dart @@ -337,9 +337,7 @@ class _EditProfilePageState extends State { ], ); }, - ).whenComplete(() { - _textController.clear(); - }); + ).whenComplete(_textController.clear); } Future _update({ diff --git a/lib/pages/member_video/controller.dart b/lib/pages/member_video/controller.dart index e4e3ef572..6f0f48e3a 100644 --- a/lib/pages/member_video/controller.dart +++ b/lib/pages/member_video/controller.dart @@ -11,7 +11,6 @@ import 'package:PiliPlus/pages/common/common_list_controller.dart'; import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; @@ -154,22 +153,26 @@ class MemberVideoCtr if (oid != null) { var bvid = IdUtils.av2bv(int.parse(oid)); var cid = await SearchHttp.ab2c(aid: oid, bvid: bvid); - PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'heroTag': Utils.makeHeroTag(oid), - 'sourceType': SourceType.archive, - 'mediaId': seasonId ?? seriesId ?? mid, - 'oid': oid, - 'favTitle': '$username: ${title ?? episodicButton.text ?? '播放全部'}', - if (seriesId == null) 'count': count.value, - if (seasonId != null || seriesId != null) - 'mediaType': params['page_type'], - 'desc': params['desc'] == '1', - 'sortField': params['sort_field'], - 'isContinuePlaying': true, - }, - ); + if (cid != null) { + PageUtils.toVideoPage( + aid: int.parse(oid), + bvid: bvid, + cid: cid, + extraArguments: { + 'sourceType': SourceType.archive, + 'mediaId': seasonId ?? seriesId ?? mid, + 'oid': oid, + 'favTitle': + '$username: ${title ?? episodicButton.text ?? '播放全部'}', + if (seriesId == null) 'count': count.value, + if (seasonId != null || seriesId != null) + 'mediaType': params['page_type'], + 'desc': params['desc'] == '1', + 'sortField': params['sort_field'], + 'isContinuePlaying': true, + }, + ); + } } return; } @@ -195,10 +198,11 @@ class MemberVideoCtr ? !desc : desc; PageUtils.toVideoPage( - 'bvid=${element.bvid}&cid=${element.cid}', - arguments: { - 'videoItem': element, - 'heroTag': Utils.makeHeroTag(element.bvid), + bvid: element.bvid, + cid: element.cid!, + cover: element.cover, + title: element.title, + extraArguments: { 'sourceType': SourceType.archive, 'mediaId': seasonId ?? seriesId ?? mid, 'oid': IdUtils.bv2av(element.bvid!), diff --git a/lib/pages/member_video/widgets/video_card_h_member_video.dart b/lib/pages/member_video/widgets/video_card_h_member_video.dart index 89e722ae1..8969023e2 100644 --- a/lib/pages/member_video/widgets/video_card_h_member_video.dart +++ b/lib/pages/member_video/widgets/video_card_h_member_video.dart @@ -11,7 +11,6 @@ import 'package:PiliPlus/models_new/space/space_archive/item.dart'; import 'package:PiliPlus/utils/date_util.dart'; import 'package:PiliPlus/utils/duration_util.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; @@ -57,10 +56,10 @@ class VideoCardHMemberVideo extends StatelessWidget { } try { PageUtils.toVideoPage( - 'bvid=${videoItem.bvid}&cid=${videoItem.cid}', - arguments: { - 'heroTag': Utils.makeHeroTag(videoItem.bvid), - }, + bvid: videoItem.bvid, + cid: videoItem.cid!, + cover: videoItem.cover, + title: videoItem.title, ); } catch (err) { SmartDialog.showToast(err.toString()); diff --git a/lib/pages/subscription_detail/widget/sub_video_card.dart b/lib/pages/subscription_detail/widget/sub_video_card.dart index a68301e08..62f0d428c 100644 --- a/lib/pages/subscription_detail/widget/sub_video_card.dart +++ b/lib/pages/subscription_detail/widget/sub_video_card.dart @@ -6,12 +6,10 @@ import 'package:PiliPlus/common/widgets/stat/stat.dart'; import 'package:PiliPlus/http/search.dart'; import 'package:PiliPlus/models/common/badge_type.dart'; import 'package:PiliPlus/models/common/stat_type.dart'; -import 'package:PiliPlus/models/common/video/video_type.dart'; import 'package:PiliPlus/models_new/sub/sub_detail/media.dart'; import 'package:PiliPlus/utils/date_util.dart'; import 'package:PiliPlus/utils/duration_util.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:flutter/material.dart'; // 收藏视频卡片 - 水平布局 @@ -34,12 +32,10 @@ class SubVideoCardH extends StatelessWidget { int? cid = await SearchHttp.ab2c(bvid: videoItem.bvid); if (cid != null) { PageUtils.toVideoPage( - 'bvid=${videoItem.bvid}&cid=$cid', - arguments: { - 'videoItem': videoItem, - 'heroTag': Utils.makeHeroTag(videoItem.id), - 'videoType': VideoType.ugc, - }, + bvid: videoItem.bvid, + cid: cid, + cover: videoItem.cover, + title: videoItem.title, ); } }, diff --git a/lib/pages/video/controller.dart b/lib/pages/video/controller.dart index c6d22adb9..99fdc1241 100644 --- a/lib/pages/video/controller.dart +++ b/lib/pages/video/controller.dart @@ -45,7 +45,6 @@ import 'package:PiliPlus/plugin/pl_player/models/heart_beat_type.dart'; import 'package:PiliPlus/plugin/pl_player/models/play_status.dart'; import 'package:PiliPlus/utils/accounts.dart'; import 'package:PiliPlus/utils/duration_util.dart'; -import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; import 'package:PiliPlus/utils/storage.dart'; import 'package:PiliPlus/utils/storage_pref.dart'; @@ -68,25 +67,27 @@ import 'package:media_kit/media_kit.dart'; class VideoDetailController extends GetxController with GetTickerProviderStateMixin { /// 路由传参 - String bvid = Get.parameters['bvid']!; - late int aid = IdUtils.bv2av(bvid); - final RxInt cid = int.parse(Get.parameters['cid']!).obs; - final heroTag = Get.arguments['heroTag']; - final RxString cover = ''.obs; + late final Map args; + late String bvid; + late int aid; + late final RxInt cid; + int? epId; + int? seasonId; + int? pgcType; + late final String heroTag; + late final RxString cover; + // 视频类型 默认投稿视频 - final pgcApi = Get.arguments['pgcApi']; - final VideoType videoType = Get.arguments['videoType'] ?? VideoType.ugc; + late final VideoType videoType; late final isUgc = videoType == VideoType.ugc; - VideoType get _actualVideoType { - if (videoType == VideoType.pgc) { - if (!Accounts.get(AccountType.video).isLogin) { - return VideoType.ugc; - } - } else if (pgcApi == true) { - return VideoType.pgc; - } - return videoType; - } + VideoType? _actualVideoType; + + // 页面来源 稍后再看 收藏夹 + late bool isPlayAll; + late SourceType sourceType; + late bool _mediaDesc = false; + late final RxList mediaList = [].obs; + late String watchLaterTitle; /// tabs相关配置 late TabController tabCtr; @@ -247,52 +248,42 @@ class VideoDetailController extends GetxController imageStatus = false; } - // 页面来源 稍后再看 收藏夹 - SourceType sourceType = Get.arguments['sourceType'] ?? SourceType.normal; - late bool _mediaDesc = false; - late final RxList mediaList = [].obs; - late String watchLaterTitle = ''; - bool get isPlayAll => sourceType != SourceType.normal; - - late dynamic epId = Get.parameters['epId']; - late dynamic seasonId = Get.parameters['seasonId']; - late dynamic subType = Get.parameters['type']; - @override void onInit() { super.onInit(); - var keys = Get.arguments.keys.toList(); - if (keys.isNotEmpty) { - if (keys.contains('pic')) { - cover.value = Get.arguments['pic'] ?? ''; - } else if (keys.contains('videoItem')) { - var args = Get.arguments['videoItem']; - try { - if (args.cover != null && args.cover != '') { - cover.value = args.cover; - } - } catch (_) { - try { - if (args.pic != null && args.pic != '') { - cover.value = args.pic; - } - } catch (_) {} - } + args = Get.arguments; + videoType = args['videoType']; + if (videoType == VideoType.pgc) { + if (!Accounts.get(AccountType.video).isLogin) { + _actualVideoType = VideoType.ugc; } + } else if (args['pgcApi'] == true) { + _actualVideoType = VideoType.pgc; } + bvid = args['bvid']; + aid = args['aid']; + cid = RxInt(args['cid']); + epId = args['epId']; + seasonId = args['seasonId']; + pgcType = args['pgcType']; + heroTag = args['heroTag']; + cover = RxString(args['cover'] ?? ''); + + sourceType = args['sourceType'] ?? SourceType.normal; + isPlayAll = sourceType != SourceType.normal; if (isPlayAll) { - watchLaterTitle = Get.arguments['favTitle']; - _mediaDesc = Get.arguments['desc']; + watchLaterTitle = args['favTitle']; + _mediaDesc = args['desc']; getMediaList(); } - bool defaultShowComment = Pref.defaultShowComment; tabCtr = TabController( length: 2, vsync: this, - initialIndex: defaultShowComment ? 1 : 0, + initialIndex: Pref.defaultShowComment ? 1 : 0, ); + autoPlay.value = Pref.autoPlayEnable; if (autoPlay.value) isShowCover.value = false; @@ -305,21 +296,20 @@ class VideoDetailController extends GetxController bool isReverse = false, bool isLoadPrevious = false, }) async { - if (!isReverse && - Get.arguments['count'] != null && - mediaList.length >= Get.arguments['count']) { + final count = args['count']; + if (!isReverse && count != null && mediaList.length >= count) { return; } var res = await UserHttp.getMediaList( - type: Get.arguments['mediaType'] ?? sourceType.mediaType, - bizId: Get.arguments['mediaId'] ?? -1, + type: args['mediaType'] ?? sourceType.mediaType, + bizId: args['mediaId'] ?? -1, ps: 20, direction: isLoadPrevious ? true : false, oid: isReverse ? null : mediaList.isEmpty - ? Get.arguments['isContinuePlaying'] == true - ? Get.arguments['oid'] + ? args['isContinuePlaying'] == true + ? args['oid'] : null : isLoadPrevious ? mediaList.first.aid @@ -332,9 +322,8 @@ class VideoDetailController extends GetxController ? mediaList.first.type : mediaList.last.type, desc: _mediaDesc, - sortField: Get.arguments['sortField'] ?? 1, - withCurrent: - mediaList.isEmpty && Get.arguments['isContinuePlaying'] == true + sortField: args['sortField'] ?? 1, + withCurrent: mediaList.isEmpty && args['isContinuePlaying'] == true ? true : false, ); @@ -376,20 +365,19 @@ class VideoDetailController extends GetxController }, panelTitle: watchLaterTitle, getBvId: () => bvid, - count: Get.arguments['count'], + count: args['count'], loadMoreMedia: getMediaList, desc: _mediaDesc, onReverse: () { _mediaDesc = !_mediaDesc; getMediaList(isReverse: true); }, - loadPrevious: Get.arguments['isContinuePlaying'] == true + loadPrevious: args['isContinuePlaying'] == true ? () => getMediaList(isLoadPrevious: true) : null, onDelete: sourceType == SourceType.watchLater || - (sourceType == SourceType.fav && - Get.arguments?['isOwner'] == true) + (sourceType == SourceType.fav && args['isOwner'] == true) ? (item, index) async { if (sourceType == SourceType.watchLater) { var res = await UserHttp.toViewDel( @@ -402,7 +390,7 @@ class VideoDetailController extends GetxController } else { var res = await FavHttp.favVideo( resources: '${item.aid}:${item.type}', - delIds: '${Get.arguments?['mediaId']}', + delIds: '${args['mediaId']}', ); if (res['status']) { mediaList.removeAt(index); @@ -1136,7 +1124,7 @@ class VideoDetailController extends GetxController autoplay: autoplay ?? autoPlay.value, epid: isUgc ? null : epId, seasonId: isUgc ? null : seasonId, - subType: isUgc ? null : subType, + pgcType: isUgc ? null : pgcType, videoType: videoType, callback: () { if (videoState.value is! Success) { @@ -1189,7 +1177,7 @@ class VideoDetailController extends GetxController epid: epId, seasonId: seasonId, tryLook: plPlayerController.tryLook, - videoType: _actualVideoType, + videoType: _actualVideoType ?? videoType, ); if (result['status']) { @@ -1204,9 +1192,10 @@ class VideoDetailController extends GetxController if (data.dash == null && data.durl != null) { videoUrl = data.durl!.first.url!; audioUrl = ''; - if (Get.arguments?['progress'] != null) { - this.defaultST = Duration(milliseconds: Get.arguments['progress']); - Get.arguments['progress'] = null; + final progress = args['progress']; + if (progress != null) { + this.defaultST = Duration(milliseconds: progress); + args['progress'] = null; } else { this.defaultST = defaultST ?? Duration.zero; } @@ -1340,9 +1329,10 @@ class VideoDetailController extends GetxController audioUrl = ''; } // - if (Get.arguments?['progress'] != null) { - this.defaultST = Duration(milliseconds: Get.arguments['progress']); - Get.arguments['progress'] = null; + final progress = args['progress']; + if (progress != null) { + this.defaultST = Duration(milliseconds: progress); + args['progress'] = null; } else { this.defaultST = defaultST ?? @@ -1577,11 +1567,12 @@ class VideoDetailController extends GetxController } void updateMediaListHistory(int aid) { - if (Get.arguments?['sortField'] != null) { + final sortField = args['sortField']; + if (sortField != null) { VideoHttp.medialistHistory( desc: _mediaDesc ? 1 : 0, oid: aid, - upperMid: Get.arguments?['mediaId'], + upperMid: sortField, ); } } @@ -1605,7 +1596,7 @@ class VideoDetailController extends GetxController cid: cid.value, epid: isUgc ? null : epId, seasonId: isUgc ? null : seasonId, - subType: isUgc ? null : subType, + pgcType: isUgc ? null : pgcType, videoType: videoType, ); } catch (_) {} diff --git a/lib/pages/video/introduction/pgc/controller.dart b/lib/pages/video/introduction/pgc/controller.dart index 174ee6220..06025fb42 100644 --- a/lib/pages/video/introduction/pgc/controller.dart +++ b/lib/pages/video/introduction/pgc/controller.dart @@ -32,29 +32,38 @@ import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:get/get.dart'; class PgcIntroController extends CommonIntroController { - var seasonId = Get.parameters['seasonId'] != null - ? int.tryParse(Get.parameters['seasonId']!) - : null; - var epId = Get.parameters['epId'] != null - ? int.tryParse(Get.parameters['epId']!) - : null; + int? seasonId; + int? epId; - late final String pgcType = - Get.parameters['type'] == '1' || Get.parameters['type'] == '4' + late final String pgcType = pgcItem.type == 1 || pgcItem.type == 4 ? '追番' : '追剧'; - final isPgc = Get.arguments['videoType'] == VideoType.pgc; - final PgcInfoModel pgcItem = Get.arguments['pgcItem']; + late final bool isPgc; + late final PgcInfoModel pgcItem; + + @override + (Object, int) getFavRidType() => (epId!, 24); + + @override + StatDetail? getStat() => pgcItem.stat; + + late final RxBool isFollowed = false.obs; + late final RxInt followStatus = (-1).obs; @override void onInit() { + final args = Get.arguments; + seasonId = args['seasonId']; + epId = args['epId']; + isPgc = args['videoType'] == VideoType.pgc; + pgcItem = args['pgcItem']; + super.onInit(); + if (isPgc) { if (accountService.isLogin.value) { - if (seasonId != null) { - queryIsFollowed(); - } + queryIsFollowed(); if (epId != null) { queryPgcLikeCoinFav(); } @@ -125,12 +134,6 @@ class PgcIntroController extends CommonIntroController { ); } - @override - (Object, int) getFavRidType() => (epId!, 24); - - @override - StatDetail? getStat() => pgcItem.stat; - // 分享视频 void actionShareVideo(BuildContext context) { showDialog( @@ -202,12 +205,12 @@ class PgcIntroController extends CommonIntroController { 6:漫画 7:综艺 // 4099 */ - dynType: switch (Get.parameters['type']) { - '1' => 4097, - '2' => 4098, - '3' => 4101, - '4' => 4100, - '5' || '7' => 4099, + dynType: switch (pgcItem.type) { + 1 => 4097, + 2 => 4098, + 3 => 4101, + 4 => 4100, + 5 || 7 => 4099, _ => -1, }, pic: pgcItem.cover, @@ -283,16 +286,15 @@ class PgcIntroController extends CommonIntroController { this.epId = epId; this.bvid = bvid; - final videoDetailCtr = - Get.find(tag: Get.arguments['heroTag']) - ..plPlayerController.pause() - ..makeHeartBeat() - ..onReset() - ..epId = epId - ..bvid = bvid - ..aid = aid - ..cid.value = cid - ..queryVideoUrl(); + final videoDetailCtr = Get.find(tag: heroTag) + ..plPlayerController.pause() + ..makeHeartBeat() + ..onReset() + ..epId = epId + ..bvid = bvid + ..aid = aid + ..cid.value = cid + ..queryVideoUrl(); if (cover != null && cover.isNotEmpty) { videoDetailCtr.cover.value = cover; } @@ -300,7 +302,7 @@ class PgcIntroController extends CommonIntroController { // 重新请求评论 if (videoDetailCtr.showReply) { try { - Get.find(tag: Get.arguments['heroTag']) + Get.find(tag: heroTag) ..aid = aid ..onReload(); } catch (_) {} @@ -353,7 +355,7 @@ class PgcIntroController extends CommonIntroController { bool prevPlay() { final episodes = pgcItem.episodes!; VideoDetailController videoDetailCtr = Get.find( - tag: Get.arguments['heroTag'], + tag: heroTag, ); int currentIndex = episodes.indexWhere( (e) => e.cid == videoDetailCtr.cid.value, @@ -377,7 +379,7 @@ class PgcIntroController extends CommonIntroController { try { final episodes = pgcItem.episodes!; VideoDetailController videoDetailCtr = Get.find( - tag: Get.arguments['heroTag'], + tag: heroTag, ); PlayRepeat playRepeat = videoDetailCtr.plPlayerController.playRepeat; @@ -437,9 +439,6 @@ class PgcIntroController extends CommonIntroController { } } - RxBool isFollowed = false.obs; - RxInt followStatus = (-1).obs; - void queryIsFollowed() { // try { // var result = await Request().get( @@ -469,14 +468,14 @@ class PgcIntroController extends CommonIntroController { @override void queryVideoIntro([EpisodeItem? episode]) { episode ??= pgcItem.episodes!.firstWhere((e) => e.cid == cid.value); + videoDetail + ..value.title = episode.showTitle + ..refresh(); videoPlayerServiceHandler.onVideoDetailChange( episode, cid.value, heroTag, artist: pgcItem.title, ); - videoDetail - ..value.title = episode.showTitle - ..refresh(); } } diff --git a/lib/pages/video/introduction/ugc/controller.dart b/lib/pages/video/introduction/ugc/controller.dart index 4b3ac7db8..5f0578424 100644 --- a/lib/pages/video/introduction/ugc/controller.dart +++ b/lib/pages/video/introduction/ugc/controller.dart @@ -79,19 +79,7 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { }); } - try { - var videoItem = Get.arguments['videoItem']; - if (videoItem != null) { - if (videoItem.title case String e) { - videoDetail.value.title = e; - } else if (videoItem.title case List list) { - videoDetail.value.title = list.fold( - '', - (prev, val) => prev + val['text'], - ); - } - } - } catch (_) {} + videoDetail.value.title = Get.arguments['title'] ?? ''; } // 获取视频简介&分p @@ -481,11 +469,9 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { if (videoDetailCtr.mediaList.indexWhere((item) => item.bvid == bvid) == -1) { PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'pic': ?cover, - 'heroTag': Utils.makeHeroTag(bvid), - }, + bvid: bvid, + cid: cid, + cover: cover, ); return; } @@ -690,10 +676,8 @@ class UgcIntroController extends CommonIntroController with ReloadMixin { if (Get.isRegistered(tag: heroTag)) { relatedCtr = Get.find(tag: heroTag); } else { - relatedCtr = Get.put(RelatedController(false), tag: heroTag) - ..queryData().whenComplete(() { - playRelated(); - }); + relatedCtr = Get.put(RelatedController(autoQuery: false), tag: heroTag) + ..queryData().whenComplete(playRelated); return false; } diff --git a/lib/pages/video/introduction/ugc/view.dart b/lib/pages/video/introduction/ugc/view.dart index 672b67a5e..fc63bb7e9 100644 --- a/lib/pages/video/introduction/ugc/view.dart +++ b/lib/pages/video/introduction/ugc/view.dart @@ -66,8 +66,7 @@ class _UgcIntroPanelState extends State @override void initState() { super.initState(); - ugcIntroController = Get.put(UgcIntroController(), tag: widget.heroTag) - ..heroTag = widget.heroTag; + ugcIntroController = Get.put(UgcIntroController(), tag: widget.heroTag); } @override diff --git a/lib/pages/video/related/controller.dart b/lib/pages/video/related/controller.dart index 14af3fab3..9773e0b05 100644 --- a/lib/pages/video/related/controller.dart +++ b/lib/pages/video/related/controller.dart @@ -6,15 +6,14 @@ import 'package:get/get.dart'; class RelatedController extends CommonListController?, HotVideoItemModel> { - RelatedController([this.autoQuery]); - // 视频aid - String bvid = Get.parameters['bvid'] ?? ""; - final bool? autoQuery; + RelatedController({this.autoQuery = true}); + String bvid = Get.arguments['bvid']; + final bool autoQuery; @override void onInit() { super.onInit(); - if (autoQuery != false) { + if (autoQuery) { queryData(); } } diff --git a/lib/pages/video/reply/controller.dart b/lib/pages/video/reply/controller.dart index b0a334749..2eb19e3cd 100644 --- a/lib/pages/video/reply/controller.dart +++ b/lib/pages/video/reply/controller.dart @@ -62,17 +62,9 @@ class VideoReplyController extends ReplyController return response.replies; } - int get _epId { - return switch (videoCtr.epId) { - int e => e, - String e => int.parse(e), - _ => throw UnsupportedError(''), - }; - } - @override Future> customGetData() => ReplyGrpc.mainList( - oid: isPugv ? _epId : aid, + oid: isPugv ? videoCtr.epId! : aid, type: videoType.replyType, mode: mode.value, cursorNext: cursorNext, diff --git a/lib/pages/video/view.dart b/lib/pages/video/view.dart index 9c0ddf8c1..5d0afbca1 100644 --- a/lib/pages/video/view.dart +++ b/lib/pages/video/view.dart @@ -74,6 +74,8 @@ class VideoDetailPageV extends StatefulWidget { class _VideoDetailPageVState extends State with TickerProviderStateMixin, RouteAware, WidgetsBindingObserver { + final heroTag = Get.arguments['heroTag']; + late final VideoDetailController videoDetailController; late final VideoReplyController _videoReplyController; PlPlayerController? plPlayerController; @@ -86,8 +88,6 @@ class _VideoDetailPageVState extends State ScrollController get introScrollController => _introScrollController ??= ScrollController(); - late String heroTag; - bool get autoExitFullscreen => videoDetailController.plPlayerController.autoExitFullscreen; bool get autoPlayEnable => @@ -130,9 +130,6 @@ class _VideoDetailPageVState extends State super.initState(); PlPlayerController.setPlayCallBack(playCallBack); - if (Get.arguments != null && Get.arguments['heroTag'] != null) { - heroTag = Get.arguments['heroTag']; - } videoDetailController = Get.put(VideoDetailController(), tag: heroTag); if (videoDetailController.showReply) { diff --git a/lib/pages/webview/view.dart b/lib/pages/webview/view.dart index 032e3c9ef..9092db9f1 100644 --- a/lib/pages/webview/view.dart +++ b/lib/pages/webview/view.dart @@ -34,7 +34,7 @@ class _WebviewPageState extends State { widget.uaType ?? UaType.values.byName(Get.parameters['uaType'] ?? 'mob'); final RxString title = ''.obs; final RxDouble progress = 1.0.obs; - bool? _inApp; + bool _inApp = false; bool _off = false; InAppWebViewController? _webViewController; @@ -42,9 +42,9 @@ class _WebviewPageState extends State { @override void initState() { super.initState(); - if (Get.arguments is Map) { - _inApp = Get.arguments['inApp']; - _off = Get.arguments['off'] ?? false; + if (Get.arguments case Map map) { + _inApp = map['inApp'] ?? false; + _off = map['off'] ?? false; } } @@ -297,7 +297,7 @@ class _WebviewPageState extends State { return null; }, shouldOverrideUrlLoading: (controller, navigationAction) async { - if (_inApp == true) { + if (_inApp) { return NavigationActionPolicy.ALLOW; } late String url = navigationAction.request.url.toString(); diff --git a/lib/pages/whisper_detail/widget/chat_item.dart b/lib/pages/whisper_detail/widget/chat_item.dart index 116fa69a6..d68028dc4 100644 --- a/lib/pages/whisper_detail/widget/chat_item.dart +++ b/lib/pages/whisper_detail/widget/chat_item.dart @@ -17,7 +17,6 @@ import 'package:PiliPlus/utils/extension.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/image_util.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; @@ -325,11 +324,9 @@ class ChatItem extends StatelessWidget { SmartDialog.dismiss(); if (cid != null) { PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'pic': i['cover_url'], - 'heroTag': Utils.makeHeroTag(bvid), - }, + bvid: bvid, + cid: cid, + cover: i['cover_url'], ); } } catch (err) { @@ -414,11 +411,9 @@ class ChatItem extends StatelessWidget { SmartDialog.dismiss(); if (cid != null) { PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'pic': content['cover'], - 'heroTag': Utils.makeHeroTag(bvid), - }, + bvid: bvid, + cid: cid, + cover: content['cover'], ); } } catch (err) { @@ -500,11 +495,10 @@ class ChatItem extends StatelessWidget { SmartDialog.dismiss(); if (cid != null) { PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'pic': content['thumb'], - 'heroTag': Utils.makeHeroTag(bvid), - }, + aid: aid, + bvid: bvid, + cid: cid, + cover: content['thumb'], ); } }; diff --git a/lib/plugin/pl_player/controller.dart b/lib/plugin/pl_player/controller.dart index c2150aef4..2fcafd41c 100644 --- a/lib/plugin/pl_player/controller.dart +++ b/lib/plugin/pl_player/controller.dart @@ -119,11 +119,11 @@ class PlPlayerController { // 记录历史记录 int? _aid; - String _bvid = ''; - int _cid = 0; - dynamic _epid; - dynamic _seasonId; - dynamic _subType; + String? _bvid; + int? _cid; + int? _epid; + int? _seasonId; + int? _pgcType; VideoType _videoType = VideoType.ugc; int _heartDuration = 0; int? width; @@ -148,8 +148,8 @@ class PlPlayerController { // final Durations durations; - String get bvid => _bvid; - int get cid => _cid; + String get bvid => _bvid!; + int get cid => _cid!; /// 数据加载监听 Stream get onDataStatusChanged => dataStatus.status.stream; @@ -530,11 +530,11 @@ class PlPlayerController { bool? isVertical, // 记录历史记录 int? aid, - String bvid = '', - int cid = 0, - dynamic epid, - dynamic seasonId, - dynamic subType, + String? bvid, + int? cid, + int? epid, + int? seasonId, + int? pgcType, VideoType? videoType, VoidCallback? callback, }) async { @@ -560,7 +560,7 @@ class PlPlayerController { _cid = cid; _epid = epid; _seasonId = seasonId; - _subType = subType; + _pgcType = pgcType; if (showSeekPreview) { videoShot = null; @@ -648,15 +648,14 @@ class PlPlayerController { return shadersDirectory; } - late final _isPgc = - Get.parameters['type'] == '1' || Get.parameters['type'] == '4'; - late int superResolutionType = _isPgc ? Pref.superResolutionType : 0; + late final isAnim = _pgcType == 1 || _pgcType == 4; + late int superResolutionType = isAnim ? Pref.superResolutionType : 0; Future setShader([int? type, NativePlayer? pp]) async { if (type == null) { type ??= superResolutionType; } else { superResolutionType = type; - if (_isPgc) { + if (isAnim) { GStorage.setting.put(SettingBoxKey.superResolutionType, type); } } @@ -714,7 +713,7 @@ class PlPlayerController { ); var pp = player.platform as NativePlayer; if (_videoPlayerController == null) { - if (_isPgc) { + if (isAnim) { setShader(superResolutionType, pp); } String audioNormalization = Pref.audioNormalization; @@ -1448,7 +1447,7 @@ class PlPlayerController { dynamic cid, dynamic epid, dynamic seasonId, - dynamic subType, + dynamic pgcType, VideoType? videoType, }) async { if (!enableHeart || MineController.anonymity.value || progress == 0) { @@ -1477,7 +1476,7 @@ class PlPlayerController { progress: isComplete ? -1 : progress, epid: epid ?? _epid, seasonId: seasonId ?? _seasonId, - subType: subType ?? _subType, + subType: pgcType ?? _pgcType, videoType: videoType ?? _videoType, ); return; @@ -1492,7 +1491,7 @@ class PlPlayerController { progress: progress, epid: epid ?? _epid, seasonId: seasonId ?? _seasonId, - subType: subType ?? _subType, + subType: pgcType ?? _pgcType, videoType: videoType ?? _videoType, ); } diff --git a/lib/plugin/pl_player/view.dart b/lib/plugin/pl_player/view.dart index 9a957a415..30beca68f 100644 --- a/lib/plugin/pl_player/view.dart +++ b/lib/plugin/pl_player/view.dart @@ -380,8 +380,7 @@ class _PLVideoPlayerState extends State ), /// 超分辨率 - BottomControlType.superResolution: - Get.parameters['type'] == '1' || Get.parameters['type'] == '4' + BottomControlType.superResolution: plPlayerController.isAnim ? Container( height: 30, margin: const EdgeInsets.symmetric(horizontal: 10), diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index d2d7e76a2..35c988d4c 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -165,15 +165,14 @@ class PiliScheme { String? aid = uriDigitRegExp.firstMatch(path)?.group(1); String? bvid = IdUtils.bvRegex.firstMatch(path)?.group(0); if (aid != null || bvid != null) { - if (queryParameters['cid'] != null) { + final cid = queryParameters['cid']; + if (cid != null) { bvid ??= IdUtils.av2bv(int.parse(aid!)); + final progress = queryParameters['dm_progress']; PageUtils.toVideoPage( - 'bvid=$bvid&cid=${queryParameters['cid']}', - arguments: { - 'heroTag': Utils.makeHeroTag(aid), - if (queryParameters['dm_progress'] != null) - 'progress': int.tryParse(queryParameters['dm_progress']!), - }, + bvid: bvid, + cid: int.parse(cid), + progress: progress == null ? null : int.parse(progress), off: off, preventDuplicates: false, ); @@ -639,13 +638,12 @@ class PiliScheme { final int? cid = await SearchHttp.ab2c(bvid: bvid); if (cid != null) { PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'heroTag': Utils.makeHeroTag(bvid), + bvid: bvid, + cid: cid, + extraArguments: { 'sourceType': SourceType.playlist, 'favTitle': '播放列表', 'mediaId': mediaId, - 'mediaType': 3, 'desc': true, 'isContinuePlaying': true, }, @@ -903,11 +901,10 @@ class PiliScheme { } if (cid != null) { PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'heroTag': Utils.makeHeroTag(aid), - if (progress != null) 'progress': int.tryParse(progress), - }, + aid: aid, + bvid: bvid, + cid: cid, + progress: progress == null ? null : int.parse(progress), off: off, preventDuplicates: false, ); diff --git a/lib/utils/page_utils.dart b/lib/utils/page_utils.dart index 5ab74e899..bd9480fc0 100644 --- a/lib/utils/page_utils.dart +++ b/lib/utils/page_utils.dart @@ -415,11 +415,9 @@ class PageUtils { int? cid = await SearchHttp.ab2c(bvid: bvid); if (cid != null) { toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'pic': cover, - 'heroTag': Utils.makeHeroTag(bvid), - }, + bvid: bvid, + cid: cid, + cover: cover, preventDuplicates: false, ); } @@ -459,11 +457,10 @@ class PageUtils { int? cid = await SearchHttp.ab2c(bvid: bvid); if (cid != null) { toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'pic': cover, - 'heroTag': Utils.makeHeroTag(bvid), - }, + aid: aid, + bvid: bvid, + cid: cid, + cover: cover, preventDuplicates: false, ); } @@ -666,29 +663,49 @@ class PageUtils { ); } - static void toVideoPage( - String page, { - dynamic arguments, + static void toVideoPage({ + VideoType videoType = VideoType.ugc, + int? aid, + String? bvid, + required int cid, + int? seasonId, + int? epId, + int? pgcType, + String? cover, + String? title, + int? progress, + Map? extraArguments, int? id, bool preventDuplicates = true, - Map? parameters, bool off = false, }) { + final arguments = { + 'aid': aid ?? IdUtils.bv2av(bvid!), + 'bvid': bvid ?? IdUtils.av2bv(aid!), + 'cid': cid, + 'seasonId': ?seasonId, + 'epId': ?epId, + 'pgcType': ?pgcType, + 'cover': ?cover, + 'title': ?title, + 'progress': ?progress, + 'videoType': videoType, + 'heroTag': Utils.makeHeroTag(cid), + ...?extraArguments, + }; if (off) { Get.offNamed( - '/videoV?$page', + '/videoV', arguments: arguments, id: id, preventDuplicates: preventDuplicates, - parameters: parameters, ); } else { Get.toNamed( - '/videoV?$page', + '/videoV', arguments: arguments, id: id, preventDuplicates: preventDuplicates, - parameters: parameters, ); } } @@ -757,13 +774,16 @@ class PageUtils { epId: epId ?? data.userStatus?.progress?.lastEpId, ); toVideoPage( - 'bvid=${episode.bvid}&cid=${episode.cid}&seasonId=${data.seasonId}&epId=${episode.epId}&type=${data.type}', - arguments: { - 'pic': episode.cover, - 'heroTag': Utils.makeHeroTag(episode.cid), - 'videoType': VideoType.pgc, + videoType: VideoType.pgc, + bvid: episode.bvid!, + cid: episode.cid!, + seasonId: data.seasonId, + epId: episode.epId, + pgcType: data.type, + cover: episode.cover, + progress: progress == null ? null : int.tryParse(progress), + extraArguments: { 'pgcItem': data, - if (progress != null) 'progress': int.tryParse(progress), }, preventDuplicates: false, ); @@ -780,14 +800,18 @@ class PageUtils { if (episode.epId.toString() == epId) { // view as ugc toVideoPage( - 'bvid=${episode.bvid}&cid=${episode.cid}&seasonId=${data.seasonId}&epId=${episode.epId}', - arguments: { + videoType: VideoType.ugc, + bvid: episode.bvid!, + cid: episode.cid!, + seasonId: data.seasonId, + epId: episode.epId, + cover: episode.cover, + progress: progress == null + ? null + : int.tryParse(progress), + extraArguments: { 'pgcApi': true, - 'pic': episode.cover, - 'heroTag': Utils.makeHeroTag(episode.cid), - 'videoType': VideoType.ugc, - if (progress != null) - 'progress': int.tryParse(progress), + 'pgcItem': data, }, preventDuplicates: false, ); @@ -833,11 +857,13 @@ class PageUtils { isPgc: false, ); toVideoPage( - 'bvid=${IdUtils.av2bv(episode.aid!)}&cid=${episode.cid}&seasonId=${data.seasonId}&epId=${episode.id}', - arguments: { - 'pic': episode.cover, - 'heroTag': Utils.makeHeroTag(episode.cid), - 'videoType': VideoType.pugv, + videoType: VideoType.pugv, + aid: episode.aid!, + cid: episode.cid!, + seasonId: data.seasonId, + epId: episode.id, + cover: episode.cover, + extraArguments: { 'pgcItem': data, }, preventDuplicates: false, diff --git a/lib/utils/url_utils.dart b/lib/utils/url_utils.dart index 2c9ae7266..b433afc69 100644 --- a/lib/utils/url_utils.dart +++ b/lib/utils/url_utils.dart @@ -3,7 +3,6 @@ import 'package:PiliPlus/http/search.dart'; import 'package:PiliPlus/utils/accounts/account.dart'; import 'package:PiliPlus/utils/id_utils.dart'; import 'package:PiliPlus/utils/page_utils.dart'; -import 'package:PiliPlus/utils/utils.dart'; import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart' show kDebugMode; import 'package:flutter/material.dart'; @@ -53,10 +52,9 @@ class UrlUtils { final int? cid = await SearchHttp.ab2c(aid: aid, bvid: bvid); if (cid != null) { PageUtils.toVideoPage( - 'bvid=$bvid&cid=$cid', - arguments: { - 'heroTag': Utils.makeHeroTag(bvid), - }, + aid: aid, + bvid: bvid, + cid: cid, preventDuplicates: false, ); }