feat: Remove direct link handling from video cards and grids, and expand source retrieval to include adult sources.

This commit is contained in:
kuekhaoyang
2025-11-28 20:46:49 +08:00
parent 8d3ac02602
commit 81759ec274
6 changed files with 17 additions and 31 deletions
-1
View File
@@ -49,7 +49,6 @@ function SecretHomePage() {
results={results}
availableSources={availableSources}
loading={loading}
openDirectLinks={true}
/>
)}
+2 -3
View File
@@ -11,10 +11,9 @@ interface SearchResultsProps {
results: Video[];
availableSources: SourceBadge[];
loading: boolean;
openDirectLinks?: boolean;
}
export function SearchResults({ results, availableSources, loading, openDirectLinks = false }: SearchResultsProps) {
export function SearchResults({ results, availableSources, loading }: SearchResultsProps) {
// Source badges hook - filters by video source
const {
selectedSources,
@@ -62,7 +61,7 @@ export function SearchResults({ results, availableSources, loading, openDirectLi
)}
{/* Display filtered videos (both source and type filters applied) */}
<VideoGrid videos={finalFilteredVideos} openDirectLinks={openDirectLinks} />
<VideoGrid videos={finalFilteredVideos} />
</div>
);
}
+2 -2
View File
@@ -15,7 +15,7 @@ interface VideoCardProps {
videoUrl: string;
cardId: string;
isActive: boolean;
onCardClick: (e: React.MouseEvent, cardId: string, videoUrl: string, video: Video) => void;
onCardClick: (e: React.MouseEvent, cardId: string, videoUrl: string) => void;
}
export const VideoCard = memo<VideoCardProps>(({
@@ -35,7 +35,7 @@ export const VideoCard = memo<VideoCardProps>(({
<Link
key={cardId}
href={videoUrl}
onClick={(e) => onCardClick(e, cardId, videoUrl, video)}
onClick={(e) => onCardClick(e, cardId, videoUrl)}
role="listitem"
aria-label={`${video.vod_name}${video.vod_remarks ? ` - ${video.vod_remarks}` : ''}`}
prefetch={false}
+3 -22
View File
@@ -8,10 +8,9 @@ import { Video } from '@/lib/types';
interface VideoGridProps {
videos: Video[];
className?: string;
openDirectLinks?: boolean;
}
export const VideoGrid = memo(function VideoGrid({ videos, className = '', openDirectLinks = false }: VideoGridProps) {
export const VideoGrid = memo(function VideoGrid({ videos, className = '' }: VideoGridProps) {
const [activeCardId, setActiveCardId] = useState<string | null>(null);
const [visibleCount, setVisibleCount] = useState(24);
const gridRef = useRef<HTMLDivElement>(null);
@@ -37,25 +36,7 @@ export const VideoGrid = memo(function VideoGrid({ videos, className = '', openD
}, []);
// Memoize the click handler to prevent re-renders
const handleCardClick = useCallback((e: React.MouseEvent, videoId: string, videoUrl: string, video?: Video) => {
if (openDirectLinks && video?.vod_play_url) {
// For secret page: extract first video URL and open directly
e.preventDefault();
const playUrls = video.vod_play_url.split('$$$');
if (playUrls.length > 0) {
const firstPlaylist = playUrls[0];
const segments = firstPlaylist.split('#');
if (segments.length > 0) {
const urls = segments[0].split('$');
if (urls.length > 1) {
window.open(urls[1], '_blank');
return;
}
}
}
return;
}
const handleCardClick = useCallback((e: React.MouseEvent, videoId: string, videoUrl: string) => {
// Check if it's a mobile device
const isMobile = window.innerWidth < 1024; // lg breakpoint
@@ -71,7 +52,7 @@ export const VideoGrid = memo(function VideoGrid({ videos, className = '', openD
}
}
// On desktop, let the Link work normally
}, [activeCardId, openDirectLinks]);
}, [activeCardId]);
// Memoize video items to prevent unnecessary re-computations
const videoItems = useMemo(() => {
+10 -2
View File
@@ -5,12 +5,20 @@
import type { VideoSource } from '@/lib/types';
import { DEFAULT_SOURCES } from './default-sources';
import { ADULT_SOURCES } from './adult-sources';
/**
* Get source by ID
* Get source by ID from both default and adult sources
*/
export function getSourceById(id: string): VideoSource | undefined {
return DEFAULT_SOURCES.find(source => source.id === id);
// Search in default sources first
const defaultSource = DEFAULT_SOURCES.find(source => source.id === id);
if (defaultSource) {
return defaultSource;
}
// Search in adult sources
return ADULT_SOURCES.find(source => source.id === id);
}
-1
View File
@@ -26,7 +26,6 @@ export interface VideoItem {
vod_actor?: string;
vod_director?: string;
vod_content?: string;
vod_play_url?: string;
source: string;
latency?: number; // Response time in milliseconds
}