From a9996443d94d7144658aab540b585f9603917092 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Tue, 2 Dec 2025 01:26:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=9B=E5=85=A5=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E5=BC=B9=E5=B9=95=E9=94=99=E8=AF=AF=E9=9B=86=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E6=96=B0=E5=A2=9E=E5=BC=B9=E5=B9=95=E6=9D=A1=E6=95=B0?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/play/page.tsx | 78 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 64 insertions(+), 14 deletions(-) diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 360ca7b..fc098bc 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -175,6 +175,7 @@ function PlayPageClient() { Array<{ episodeId: number; episodeTitle: string }> >([]); const [danmakuLoading, setDanmakuLoading] = useState(false); + const [danmakuCount, setDanmakuCount] = useState(0); const danmakuPluginRef = useRef(null); const danmakuSettingsRef = useRef(danmakuSettings); @@ -1365,9 +1366,14 @@ function PlayPageClient() { }); danmakuPluginRef.current.load(); + setDanmakuCount(comments.length); console.log(`弹幕加载成功,共 ${comments.length} 条`); + + // 延迟一下让用户看到弹幕数量 + await new Promise((resolve) => setTimeout(resolve, 1500)); } catch (error) { console.error('加载弹幕失败:', error); + setDanmakuCount(0); } finally { setDanmakuLoading(false); } @@ -1411,26 +1417,47 @@ function PlayPageClient() { // 检查是否有记忆 const memory = loadDanmakuMemory(title); if (memory) { - console.log('使用记忆的弹幕选择:', memory); - setCurrentDanmakuSelection({ - animeId: memory.animeId, - episodeId: memory.episodeId, - animeTitle: memory.animeTitle, - episodeTitle: memory.episodeTitle, - }); + console.log('使用记忆的弹幕动漫:', memory.animeTitle); // 获取该动漫的所有剧集列表 try { const episodesResult = await getEpisodes(memory.animeId); if (episodesResult.success && episodesResult.bangumi.episodes.length > 0) { setDanmakuEpisodesList(episodesResult.bangumi.episodes); + + // 根据当前集数选择对应的弹幕 + const currentEp = currentEpisodeIndexRef.current; + const episode = + episodesResult.bangumi.episodes[ + Math.min(currentEp, episodesResult.bangumi.episodes.length - 1) + ]; + + if (episode) { + const selection: DanmakuSelection = { + animeId: memory.animeId, + episodeId: episode.episodeId, + animeTitle: memory.animeTitle, + episodeTitle: episode.episodeTitle, + }; + + setCurrentDanmakuSelection(selection); + + // 更新选择记忆 + saveDanmakuMemory( + title, + selection.animeId, + selection.episodeId, + selection.animeTitle, + selection.episodeTitle + ); + + await loadDanmaku(episode.episodeId); + return; + } } } catch (error) { console.error('获取弹幕剧集列表失败:', error); } - - await loadDanmaku(memory.episodeId); - return; } // 自动搜索弹幕 @@ -2706,10 +2733,33 @@ function PlayPageClient() { {/* 弹幕加载蒙层 */} {danmakuLoading && (
-
- - 加载弹幕中... - + {danmakuCount > 0 ? ( + <> + + + + + 已加载 {danmakuCount} 条弹幕 + + + ) : ( + <> +
+ + 加载弹幕中... + + + )}
)}