diff --git a/lib/pages/episode_panel/view.dart b/lib/pages/episode_panel/view.dart index 58603c25..28774563 100644 --- a/lib/pages/episode_panel/view.dart +++ b/lib/pages/episode_panel/view.dart @@ -622,7 +622,7 @@ class _EpisodePanelState extends CommonSlidePageState { _tabController.animateTo(widget.initialTabIndex); await Future.delayed(const Duration(milliseconds: 225)); } - _itemScrollController[currentTabIndex].scrollTo( + _itemScrollController[widget.initialTabIndex].scrollTo( index: _currentItemIndex, duration: const Duration(milliseconds: 200), ); diff --git a/lib/pages/video/introduction/ugc/view.dart b/lib/pages/video/introduction/ugc/view.dart index ff82ab23..462836ca 100644 --- a/lib/pages/video/introduction/ugc/view.dart +++ b/lib/pages/video/introduction/ugc/view.dart @@ -305,10 +305,13 @@ class _UgcIntroPanelState extends TripleState !videoDetailCtr .plPlayerController .horizontalSeasonPanel)) - SeasonPanel( - heroTag: widget.heroTag, - showEpisodes: widget.showEpisodes, - ugcIntroController: introController, + Obx( + () => SeasonPanel( + key: ValueKey(introController.videoDetail.value), + heroTag: widget.heroTag, + showEpisodes: widget.showEpisodes, + ugcIntroController: introController, + ), ), if (!isLoading && videoDetail.pages != null && @@ -316,14 +319,16 @@ class _UgcIntroPanelState extends TripleState (isPortrait || !videoDetailCtr .plPlayerController - .horizontalSeasonPanel)) ...[ - PagesPanel( - heroTag: widget.heroTag, - ugcIntroController: introController, - bvid: introController.bvid, - showEpisodes: widget.showEpisodes, + .horizontalSeasonPanel)) + Obx( + () => PagesPanel( + key: ValueKey(introController.videoDetail.value), + heroTag: widget.heroTag, + ugcIntroController: introController, + bvid: introController.bvid, + showEpisodes: widget.showEpisodes, + ), ), - ], ], ), ), diff --git a/lib/pages/video/introduction/ugc/widgets/page.dart b/lib/pages/video/introduction/ugc/widgets/page.dart index 33d7114b..dbe9872e 100644 --- a/lib/pages/video/introduction/ugc/widgets/page.dart +++ b/lib/pages/video/introduction/ugc/widgets/page.dart @@ -8,6 +8,7 @@ import 'package:PiliPlus/utils/id_utils.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +// TODO refa class PagesPanel extends StatefulWidget { const PagesPanel({ super.key, @@ -156,7 +157,9 @@ class _PagesPanelState extends State { if (widget.showEpisodes == null) { Get.back(); } - widget.ugcIntroController.onChangeEpisode(item); + widget.ugcIntroController.onChangeEpisode( + item..bvid ??= widget.bvid, + ); if (widget.list != null && widget .ugcIntroController diff --git a/lib/pages/video/introduction/ugc/widgets/season.dart b/lib/pages/video/introduction/ugc/widgets/season.dart index 12bfe59a..60677197 100644 --- a/lib/pages/video/introduction/ugc/widgets/season.dart +++ b/lib/pages/video/introduction/ugc/widgets/season.dart @@ -8,6 +8,7 @@ import 'package:PiliPlus/pages/video/introduction/ugc/controller.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +// TODO refa class SeasonPanel extends StatefulWidget { const SeasonPanel({ super.key, diff --git a/lib/utils/app_scheme.dart b/lib/utils/app_scheme.dart index ca90246b..1d37e7fa 100644 --- a/lib/utils/app_scheme.dart +++ b/lib/utils/app_scheme.dart @@ -174,7 +174,6 @@ class PiliScheme { cid: int.parse(cid), progress: progress == null ? null : int.parse(progress), off: off, - preventDuplicates: false, ); } else { videoPush( @@ -906,7 +905,6 @@ class PiliScheme { cid: cid, progress: progress == null ? null : int.parse(progress), off: off, - preventDuplicates: false, ); } } catch (e) { diff --git a/lib/utils/page_utils.dart b/lib/utils/page_utils.dart index 4ec16f0b..05307fd4 100644 --- a/lib/utils/page_utils.dart +++ b/lib/utils/page_utils.dart @@ -441,7 +441,6 @@ class PageUtils { bvid: bvid, cid: cid, cover: cover, - preventDuplicates: false, ); } } catch (err) { @@ -484,7 +483,6 @@ class PageUtils { bvid: bvid, cid: cid, cover: cover, - preventDuplicates: false, ); } break; @@ -718,7 +716,6 @@ class PageUtils { int? progress, Map? extraArguments, int? id, - bool preventDuplicates = true, bool off = false, }) { if (PlPlayerController.instance?.isLive == true) { @@ -813,32 +810,21 @@ class PageUtils { if (result.isSuccess) { PgcInfoModel data = result.data; final episodes = data.episodes; + final hasEpisode = episodes != null && episodes.isNotEmpty; + + EpisodeItem? episode; + if (epId != null) { + epId = epId.toString(); + if (hasEpisode) { + episode = episodes.firstWhereOrNull( + (item) => item.epId.toString() == epId, + ); + } - if (episodes != null && episodes.isNotEmpty) { - final EpisodeItem episode = findEpisode( - episodes, - epId: epId ?? data.userStatus?.progress?.lastEpId, - ); - toVideoPage( - 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, - }, - preventDuplicates: false, - ); - } else { // find section - if (epId != null) { + if (episode == null) { final sections = data.section; if (sections != null && sections.isNotEmpty) { - epId = epId.toString(); for (var section in sections) { final episodes = section.episodes; if (episodes != null && episodes.isNotEmpty) { @@ -859,7 +845,6 @@ class PageUtils { 'pgcApi': true, 'pgcItem': data, }, - preventDuplicates: false, ); return; } @@ -868,8 +853,30 @@ class PageUtils { } } } - SmartDialog.showToast('资源加载失败'); } + + if (hasEpisode) { + episode ??= findEpisode( + episodes, + epId: data.userStatus?.progress?.lastEpId, + ); + toVideoPage( + 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, + }, + ); + return; + } + + SmartDialog.showToast('资源加载失败'); } else { result.toast(); } @@ -912,7 +919,6 @@ class PageUtils { extraArguments: { 'pgcItem': data, }, - preventDuplicates: false, ); } else { SmartDialog.showToast('资源加载失败'); diff --git a/lib/utils/url_utils.dart b/lib/utils/url_utils.dart index b433afc6..83ffff41 100644 --- a/lib/utils/url_utils.dart +++ b/lib/utils/url_utils.dart @@ -55,7 +55,6 @@ class UrlUtils { aid: aid, bvid: bvid, cid: cid, - preventDuplicates: false, ); } } else {