From 96f9b094e4ea66141fbdae220f164637090ba576 Mon Sep 17 00:00:00 2001 From: mtvpls Date: Thu, 18 Dec 2025 00:01:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=82=E7=9C=8B=E7=9B=B4=E6=92=AD=E4=BC=9A?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=92=AD=E6=94=BE=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/live/page.tsx | 41 +++++++++++++++++++++++++++++ src/components/ContinueWatching.tsx | 1 + src/lib/db.client.ts | 1 + 3 files changed, 43 insertions(+) diff --git a/src/app/live/page.tsx b/src/app/live/page.tsx index a55bda6..188c673 100644 --- a/src/app/live/page.tsx +++ b/src/app/live/page.tsx @@ -15,6 +15,7 @@ import { generateStorageKey, isFavorited as checkIsFavorited, saveFavorite, + savePlayRecord, subscribeToDataUpdates, } from '@/lib/db.client'; import { parseCustomTimeFormat } from '@/lib/time'; @@ -425,6 +426,25 @@ function LivePageClient() { // 异步获取初始频道的节目单(不阻塞页面加载) if (selectedChannel) { fetchEpgData(selectedChannel, source); + + // 保存播放记录 + try { + await savePlayRecord(`live_${source.key}`, `live_${selectedChannel.id}`, { + title: selectedChannel.name, + source_name: source.name, + year: '', + cover: `/api/proxy/logo?url=${encodeURIComponent(selectedChannel.logo)}&source=${source.key}`, + index: 1, + total_episodes: 1, + play_time: 0, + total_time: 0, + save_time: Date.now(), + search_title: '', + origin: 'live', + }); + } catch (err) { + console.error('保存播放记录失败:', err); + } } } @@ -570,6 +590,27 @@ function LivePageClient() { if (currentSource) { await fetchEpgData(channel, currentSource); } + + // 保存播放记录 + if (currentSource) { + try { + await savePlayRecord(`live_${currentSource.key}`, `live_${channel.id}`, { + title: channel.name, + source_name: currentSource.name, + year: '', + cover: `/api/proxy/logo?url=${encodeURIComponent(channel.logo)}&source=${currentSource.key}`, + index: 1, + total_episodes: 1, + play_time: 0, + total_time: 0, + save_time: Date.now(), + search_title: '', + origin: 'live', + }); + } catch (err) { + console.error('保存播放记录失败:', err); + } + } }; // 滚动到指定频道位置的函数 diff --git a/src/components/ContinueWatching.tsx b/src/components/ContinueWatching.tsx index 0a9d882..3bd4296 100644 --- a/src/components/ContinueWatching.tsx +++ b/src/components/ContinueWatching.tsx @@ -144,6 +144,7 @@ export default function ContinueWatching({ className }: ContinueWatchingProps) { ) } type={record.total_episodes > 1 ? 'tv' : ''} + origin={record.origin} /> ); diff --git a/src/lib/db.client.ts b/src/lib/db.client.ts index 6054174..774c8fa 100644 --- a/src/lib/db.client.ts +++ b/src/lib/db.client.ts @@ -40,6 +40,7 @@ export interface PlayRecord { total_time: number; // 总进度(秒) save_time: number; // 记录保存时间(时间戳) search_title?: string; // 搜索时使用的标题 + origin?: 'vod' | 'live'; // 来源类型 } // ---- 收藏类型 ----