/** * HistoryItem - Individual watch history item * Displays video thumbnail, title, episode, progress, and delete button */ import Image from 'next/image'; import { Icons } from '@/components/ui/Icon'; import { formatTime, formatDate } from '@/lib/utils/format-utils'; import { PosterImage } from './PosterImage'; import { FavoriteButton } from '@/components/favorites/FavoriteButton'; import type { VideoHistoryItem } from '@/lib/types'; interface HistoryItemProps { item: VideoHistoryItem; onRemove: () => void; isPremium?: boolean; } export function HistoryItem({ item, onRemove, isPremium = false }: HistoryItemProps) { const getVideoUrl = (): string => { const params = new URLSearchParams({ id: item.videoId.toString(), source: item.source, title: item.title, episode: item.episodeIndex.toString(), }); if (isPremium) { params.set('premium', '1'); } return `/player?${params.toString()}`; }; const handleClick = (event: React.MouseEvent) => { // Middle mouse or Ctrl/Cmd+click opens in new tab if (event.button === 1 || event.ctrlKey || event.metaKey) { event.preventDefault(); window.open(getVideoUrl(), '_blank'); return; } }; const progress = (item.playbackPosition / item.duration) * 100; const episodeText = item.episodes && item.episodes.length > 0 ? item.episodes[item.episodeIndex]?.name || `第${item.episodeIndex + 1}集` : ''; return (
); }