diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 4ad3b5b..87633ac 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -1773,6 +1773,7 @@ function PlayPageClient() { // 播放进度保存相关 const saveIntervalRef = useRef(null); const lastSaveTimeRef = useRef(0); + const lastSavedPlayTimeRef = useRef(null); // 下集预缓存相关 const nextEpisodePreCacheTriggeredRef = useRef(false); @@ -5703,12 +5704,17 @@ function PlayPageClient() { const player = artPlayerRef.current; const currentTime = player.currentTime || 0; const duration = player.duration || 0; + const playTime = Math.floor(currentTime); // 如果播放时间太短(少于5秒)或者视频时长无效,不保存 if (currentTime < 1 || !duration) { return; } + if (lastSavedPlayTimeRef.current === playTime) { + return; + } + try { saveLocalEpisodeProgress( episodeProgressContentKey, @@ -5724,12 +5730,13 @@ function PlayPageClient() { cover: detailRef.current?.poster || '', index: currentEpisodeIndexRef.current + 1, // 转换为1基索引 total_episodes: detailRef.current?.episodes.length || 1, - play_time: Math.floor(currentTime), + play_time: playTime, total_time: Math.floor(duration), save_time: Date.now(), search_title: searchTitle, }); + lastSavedPlayTimeRef.current = playTime; lastSaveTimeRef.current = Date.now(); console.log('播放进度已保存:', { title: videoTitleRef.current,