mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-05-22 06:17:29 +08:00
fix: play record and toggle favorites
This commit is contained in:
@@ -671,10 +671,10 @@ function PlayPageClient() {
|
|||||||
await savePlayRecord(currentSource, currentId, {
|
await savePlayRecord(currentSource, currentId, {
|
||||||
title: videoTitleRef.current,
|
title: videoTitleRef.current,
|
||||||
source_name: detailRef.current?.source_name || '',
|
source_name: detailRef.current?.source_name || '',
|
||||||
year: videoYear || detailRef.current?.year || '',
|
year: detailRef.current?.year || '',
|
||||||
cover: videoCover,
|
cover: detailRef.current?.poster || '',
|
||||||
index: currentEpisodeIndex + 1, // 转换为1基索引
|
index: currentEpisodeIndexRef.current + 1, // 转换为1基索引
|
||||||
total_episodes: totalEpisodes,
|
total_episodes: detailRef.current?.episodes.length || 1,
|
||||||
play_time: Math.floor(currentTime),
|
play_time: Math.floor(currentTime),
|
||||||
total_time: Math.floor(duration),
|
total_time: Math.floor(duration),
|
||||||
save_time: Date.now(),
|
save_time: Date.now(),
|
||||||
@@ -745,15 +745,15 @@ function PlayPageClient() {
|
|||||||
|
|
||||||
// 切换收藏
|
// 切换收藏
|
||||||
const handleToggleFavorite = async () => {
|
const handleToggleFavorite = async () => {
|
||||||
if (!currentSource || !currentId) return;
|
if (!videoTitleRef.current || !detailRef.current || !currentSourceRef.current || !currentIdRef.current) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const newState = await toggleFavorite(currentSource, currentId, {
|
const newState = await toggleFavorite(currentSourceRef.current, currentIdRef.current, {
|
||||||
title: videoTitle,
|
title: videoTitleRef.current,
|
||||||
source_name: detail?.source_name || '',
|
source_name: detailRef.current?.source_name || '',
|
||||||
year: detail?.year || videoYear || '',
|
year: detailRef.current?.year || '',
|
||||||
cover: videoCover || '',
|
cover: detailRef.current?.poster || '',
|
||||||
total_episodes: totalEpisodes || 1,
|
total_episodes: detailRef.current?.episodes.length || 1,
|
||||||
save_time: Date.now(),
|
save_time: Date.now(),
|
||||||
});
|
});
|
||||||
setFavorited(newState);
|
setFavorited(newState);
|
||||||
|
|||||||
Reference in New Issue
Block a user