opt find pgc episode

tweak

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-08-10 15:43:31 +08:00
parent 8fbc8fda3d
commit 745a510ffa
7 changed files with 56 additions and 44 deletions

View File

@@ -622,7 +622,7 @@ class _EpisodePanelState extends CommonSlidePageState<EpisodePanel> {
_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),
);

View File

@@ -305,25 +305,30 @@ class _UgcIntroPanelState extends TripleState<UgcIntroPanel>
!videoDetailCtr
.plPlayerController
.horizontalSeasonPanel))
SeasonPanel(
Obx(
() => SeasonPanel(
key: ValueKey(introController.videoDetail.value),
heroTag: widget.heroTag,
showEpisodes: widget.showEpisodes,
ugcIntroController: introController,
),
),
if (!isLoading &&
videoDetail.pages != null &&
videoDetail.pages!.length > 1 &&
(isPortrait ||
!videoDetailCtr
.plPlayerController
.horizontalSeasonPanel)) ...[
PagesPanel(
.horizontalSeasonPanel))
Obx(
() => PagesPanel(
key: ValueKey(introController.videoDetail.value),
heroTag: widget.heroTag,
ugcIntroController: introController,
bvid: introController.bvid,
showEpisodes: widget.showEpisodes,
),
],
),
],
),
),

View File

@@ -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<PagesPanel> {
if (widget.showEpisodes == null) {
Get.back();
}
widget.ugcIntroController.onChangeEpisode(item);
widget.ugcIntroController.onChangeEpisode(
item..bvid ??= widget.bvid,
);
if (widget.list != null &&
widget
.ugcIntroController

View File

@@ -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,

View File

@@ -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) {

View File

@@ -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;
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
EpisodeItem? episode;
if (epId != null) {
epId = epId.toString();
if (hasEpisode) {
episode = episodes.firstWhereOrNull(
(item) => item.epId.toString() == epId,
);
}
// find section
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('资源加载失败');

View File

@@ -55,7 +55,6 @@ class UrlUtils {
aid: aid,
bvid: bvid,
cid: cid,
preventDuplicates: false,
);
}
} else {