修复无法切换源到私人影库

This commit is contained in:
mtvpls
2025-12-26 00:54:58 +08:00
parent 5d593bafb2
commit 712fc7489e

View File

@@ -904,6 +904,10 @@ function PlayPageClient() {
!detailData.episodes ||
episodeIndex >= detailData.episodes.length
) {
// openlist 源的剧集是懒加载的,如果 episodes 为空则跳过
if (detailData?.source === 'openlist' && (!detailData.episodes || detailData.episodes.length === 0)) {
return;
}
setVideoUrl('');
return;
}
@@ -2073,7 +2077,7 @@ function PlayPageClient() {
}
}
const newDetail = availableSources.find(
let newDetail = availableSources.find(
(source) => source.source === newSource && source.id === newId
);
if (!newDetail) {
@@ -2081,6 +2085,23 @@ function PlayPageClient() {
return;
}
// 如果是 openlist 源且 episodes 为空,需要调用 detail 接口获取完整信息
if (newDetail.source === 'openlist' && (!newDetail.episodes || newDetail.episodes.length === 0)) {
try {
const detailResponse = await fetch(`/api/detail?source=${newSource}&id=${newId}`);
if (detailResponse.ok) {
newDetail = await detailResponse.json();
} else {
throw new Error('获取 openlist 详情失败');
}
} catch (err) {
console.error('获取 openlist 详情失败:', err);
setIsVideoLoading(false);
setError('获取视频详情失败,请重试');
return;
}
}
// 尝试跳转到当前正在播放的集数
let targetIndex = currentEpisodeIndex;
@@ -2922,6 +2943,11 @@ function PlayPageClient() {
return;
}
// openlist 源的剧集是懒加载的,如果 episodes 为空则跳过检查
if ((currentSource === 'openlist' || detail?.source === 'openlist') && (!detail || !detail.episodes || detail.episodes.length === 0)) {
return;
}
// 确保选集索引有效
if (
!detail ||