移除继续播放的删除和收藏按钮

This commit is contained in:
mtvpls
2025-12-27 22:25:50 +08:00
parent 6a9777a7ca
commit 36c1b87af4
3 changed files with 50 additions and 24 deletions
+5 -1
View File
@@ -27,12 +27,14 @@ export async function GET() {
return NextResponse.json(cache.data); return NextResponse.json(cache.data);
} }
let result; let result: any;
// 根据配置的数据源获取数据 // 根据配置的数据源获取数据
if (bannerDataSource === 'TX') { if (bannerDataSource === 'TX') {
// 使用TX数据源 // 使用TX数据源
result = await getTXBannerContent(); result = await getTXBannerContent();
// 添加数据源标识
result.source = 'TX';
// 更新TX缓存 // 更新TX缓存
txCache = { txCache = {
data: result, data: result,
@@ -52,6 +54,8 @@ export async function GET() {
// 获取热门内容 // 获取热门内容
result = await getTMDBTrendingContent(apiKey, proxy); result = await getTMDBTrendingContent(apiKey, proxy);
// 添加数据源标识
result.source = 'TMDB';
// 更新TMDB缓存 // 更新TMDB缓存
tmdbCache = { tmdbCache = {
data: result, data: result,
+43 -21
View File
@@ -28,9 +28,13 @@ export default function BannerCarousel({ autoPlayInterval = 5000 }: BannerCarous
const isManualChange = useRef(false); // 标记是否为手动切换 const isManualChange = useRef(false); // 标记是否为手动切换
// LocalStorage 缓存配置 // LocalStorage 缓存配置
const LOCALSTORAGE_KEY = 'tmdb_trending_cache';
const LOCALSTORAGE_DURATION = 24 * 60 * 60 * 1000; // 1天 const LOCALSTORAGE_DURATION = 24 * 60 * 60 * 1000; // 1天
// 根据数据源获取缓存key
const getLocalStorageKey = (source: string) => {
return `banner_trending_cache_${source}`;
};
// 跳转到播放页面 // 跳转到播放页面
const handlePlay = (title: string) => { const handlePlay = (title: string) => {
router.push(`/play?title=${encodeURIComponent(title)}`); router.push(`/play?title=${encodeURIComponent(title)}`);
@@ -51,34 +55,52 @@ export default function BannerCarousel({ autoPlayInterval = 5000 }: BannerCarous
useEffect(() => { useEffect(() => {
const fetchTrending = async () => { const fetchTrending = async () => {
try { try {
// 先检查 localStorage 缓存 // 先尝试从所有可能的数据源缓存中读取
const cached = localStorage.getItem(LOCALSTORAGE_KEY); const sources = ['TMDB', 'TX'];
if (cached) { let cachedData = null;
try { let validSource = null;
const { data, timestamp } = JSON.parse(cached);
const now = Date.now(); for (const source of sources) {
const cacheKey = getLocalStorageKey(source);
// 如果缓存未过期,直接使用 const cached = localStorage.getItem(cacheKey);
if (now - timestamp < LOCALSTORAGE_DURATION) {
setItems(data); if (cached) {
setIsLoading(false); try {
return; const { data, timestamp } = JSON.parse(cached);
const now = Date.now();
// 如果缓存未过期,使用缓存数据
if (now - timestamp < LOCALSTORAGE_DURATION) {
cachedData = data;
validSource = source;
break;
}
} catch (e) {
console.error('解析缓存数据失败:', e);
} }
} catch (e) {
// 缓存解析失败,继续请求 API
console.error('解析缓存数据失败:', e);
} }
} }
// 从 API 获取数据 // 如果有有效的缓存,直接使用,不请求API
if (cachedData) {
setItems(cachedData);
setIsLoading(false);
return;
}
// 没有缓存或缓存过期,从 API 获取数据
const response = await fetch('/api/tmdb/trending'); const response = await fetch('/api/tmdb/trending');
const result = await response.json(); const result = await response.json();
if (result.code === 200 && result.list.length > 0) { if (result.code === 200 && result.list.length > 0) {
const dataSource = result.source || 'TMDB'; // 获取数据源标识
const cacheKey = getLocalStorageKey(dataSource);
setItems(result.list); setItems(result.list);
// 保存到 localStorage // 保存到 localStorage(使用数据源特定的key
try { try {
localStorage.setItem(LOCALSTORAGE_KEY, JSON.stringify({ localStorage.setItem(cacheKey, JSON.stringify({
data: result.list, data: result.list,
timestamp: Date.now() timestamp: Date.now()
})); }));
@@ -95,7 +117,7 @@ export default function BannerCarousel({ autoPlayInterval = 5000 }: BannerCarous
}; };
fetchTrending(); fetchTrending();
}, [LOCALSTORAGE_KEY, LOCALSTORAGE_DURATION]); }, []);
// 自动播放 // 自动播放
useEffect(() => { useEffect(() => {
+2 -2
View File
@@ -718,8 +718,8 @@ const VideoCard = forwardRef<VideoCardHandle, VideoCardProps>(function VideoCard
</div> </div>
)} )}
{/* 操作按钮 */} {/* 操作按钮 - 继续观看不显示桌面端悬停按钮 */}
{(config.showHeart || config.showCheckCircle) && ( {(config.showHeart || config.showCheckCircle) && from !== 'playrecord' && (
<div <div
data-button="true" data-button="true"
className='absolute bottom-3 right-3 flex gap-3 opacity-0 translate-y-2 transition-all duration-300 ease-in-out sm:group-hover:opacity-100 sm:group-hover:translate-y-0' className='absolute bottom-3 right-3 flex gap-3 opacity-0 translate-y-2 transition-all duration-300 ease-in-out sm:group-hover:opacity-100 sm:group-hover:translate-y-0'