From b5130225463ea9418748eb924a6ef6dff3224f42 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Wed, 10 Dec 2025 21:07:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=BC=B9=E5=B9=95=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/play/page.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 2f2260a..bcdc372 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -395,6 +395,8 @@ function PlayPageClient() { ]); // 监听剧集切换,自动加载对应的弹幕 + const lastLoadedEpisodeIdRef = useRef(null); + useEffect(() => { // 只有在有弹幕选择且有剧集列表时才自动切换 if ( @@ -404,6 +406,12 @@ function PlayPageClient() { ) { const episode = danmakuEpisodesList[currentEpisodeIndex]; if (episode && episode.episodeId !== currentDanmakuSelection.episodeId) { + // 避免重复加载同一集的弹幕 + if (lastLoadedEpisodeIdRef.current === episode.episodeId) { + console.log(`跳过重复加载弹幕: episodeId=${episode.episodeId}`); + return; + } + // 自动加载新集数的弹幕 const newSelection: DanmakuSelection = { animeId: currentDanmakuSelection.animeId, @@ -412,6 +420,7 @@ function PlayPageClient() { episodeTitle: episode.episodeTitle, }; setCurrentDanmakuSelection(newSelection); + lastLoadedEpisodeIdRef.current = episode.episodeId; loadDanmaku(episode.episodeId); console.log(`自动切换弹幕到第 ${currentEpisodeIndex + 1} 集`); }