'use client'; // Add this to ensure it's a client component import React, { useState } from 'react'; import { Edit2, Trash2, Play } from 'lucide-react'; import { Button } from '@/components/ui/button'; import dynamic from 'next/dynamic'; interface VideoGridLayoutProps { videos: { id: string; url: string; title: string; date?: string; }[]; onEdit?: (id: string) => void; onDelete?: (id: string) => void; } function VideoGridLayoutComponent({ videos, onEdit, onDelete }: VideoGridLayoutProps) { const [hoveredId, setHoveredId] = useState(null); const [isPlaying, setIsPlaying] = useState<{ [key: string]: boolean }>({}); const handleMouseEnter = (id: string) => { setHoveredId(id); }; const handleMouseLeave = (id: string) => { setHoveredId(null); // 暂停视频 const video = document.getElementById(`video-${id}`) as HTMLVideoElement; if (video) { video.pause(); setIsPlaying(prev => ({ ...prev, [id]: false })); } }; const togglePlay = (id: string) => { const video = document.getElementById(`video-${id}`) as HTMLVideoElement; if (video) { if (video.paused) { video.play(); setIsPlaying(prev => ({ ...prev, [id]: true })); } else { video.pause(); setIsPlaying(prev => ({ ...prev, [id]: false })); } } }; return (
{videos.map((video) => (
handleMouseEnter(video.id)} onMouseLeave={() => handleMouseLeave(video.id)} > {/* 视频容器 */}
{/* 视频信息 */}

{video.title}

{video.date && (

{video.date}

)}
))}
); } // Export as a client-only component to prevent hydration issues export const VideoGridLayout = dynamic(() => Promise.resolve(VideoGridLayoutComponent), { ssr: false });