'use client'; // Add this to ensure it's a client component import React, { useState, useRef, useEffect } from 'react'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { Button } from '@/components/ui/button'; import dynamic from 'next/dynamic'; interface VideoScreenLayoutProps { videos: { id: string; url: string; title: string; }[]; } function VideoScreenLayoutComponent({ videos }: VideoScreenLayoutProps) { const [currentIndex, setCurrentIndex] = useState(0); const [isAnimating, setIsAnimating] = useState(false); const containerRef = useRef(null); // 计算每个面板的样式 const getPanelStyle = (index: number) => { const position = index - currentIndex; const scale = Math.max(0.6, 1 - Math.abs(position) * 0.2); const zIndex = 10 - Math.abs(position); const opacity = Math.max(0.4, 1 - Math.abs(position) * 0.3); let transform = ` perspective(1000px) scale(${scale}) translateX(${position * 100}%) `; // 添加侧面板的 3D 旋转效果 if (position !== 0) { const rotateY = position > 0 ? -15 : 15; transform += ` rotateY(${rotateY}deg)`; } return { transform, zIndex, opacity, }; }; // 处理切换 const handleSlide = (direction: 'prev' | 'next') => { if (isAnimating) return; setIsAnimating(true); const newIndex = direction === 'next' ? (currentIndex + 1) % videos.length : (currentIndex - 1 + videos.length) % videos.length; setCurrentIndex(newIndex); // 动画结束后重置状态 setTimeout(() => setIsAnimating(false), 500); }; return (
{/* 视频面板容器 */}
{videos.map((video, index) => (
{/* 视频 - Add suppressHydrationWarning to prevent className mismatch warnings */}
))}
{/* 切换按钮 */}
); } // Export as a client-only component to prevent hydration issues export const VideoScreenLayout = dynamic(() => Promise.resolve(VideoScreenLayoutComponent), { ssr: false });