'use client'; import { useState, useEffect } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { XMarkIcon, PlayIcon, PauseIcon, ArrowPathIcon, ForwardIcon} from '@heroicons/react/24/outline'; import SkinViewer from './SkinViewer'; interface SkinDetailModalProps { isOpen: boolean; onClose: () => void; texture: { id: number; name: string; url: string; type: 'SKIN' | 'CAPE'; is_slim?: boolean; description?: string; favorite_count?: number; download_count?: number; created_at?: string; uploader?: { username: string; }; } | null; } export default function SkinDetailModal({ isOpen, onClose, texture }: SkinDetailModalProps) { const [isPlaying, setIsPlaying] = useState(false); const [currentAnimation, setCurrentAnimation] = useState<'idle' | 'walking' | 'running' | 'jumping'>('idle'); const [autoRotate, setAutoRotate] = useState(true); const [rotation, setRotation] = useState(true); // 重置状态当对话框关闭时 useEffect(() => { if (!isOpen) { setIsPlaying(false); setCurrentAnimation('idle'); setAutoRotate(true); setRotation(true); } }, [isOpen]); // 键盘事件处理 useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (!isOpen) return; switch (e.key) { case 'Escape': onClose(); break; case ' ': e.preventDefault(); setIsPlaying(!isPlaying); break; case '1': setCurrentAnimation('idle'); break; case '2': setCurrentAnimation('walking'); break; case '3': setCurrentAnimation('running'); break; case '4': setCurrentAnimation('jumping'); break; } }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [isOpen, onClose, isPlaying]); if (!texture) return null; return ( {isOpen && ( e.stopPropagation()} > {/* Header */}

{texture.name}

{texture.type === 'SKIN' ? '皮肤' : '披风'} {texture.is_slim && ( 细臂 )}
{/* 3D 预览区域 */}
{/* 控制面板 */}
{/* 动画控制 */}

动画控制

setCurrentAnimation('idle')} className={`p-3 rounded-lg text-sm font-medium transition-all duration-200 ${ currentAnimation === 'idle' ? 'bg-orange-500 text-white shadow-lg' : 'bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 border border-gray-200 dark:border-gray-600' }`} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > 静止 setCurrentAnimation('walking')} className={`p-3 rounded-lg text-sm font-medium transition-all duration-200 ${ currentAnimation === 'walking' ? 'bg-orange-500 text-white shadow-lg' : 'bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 border border-gray-200 dark:border-gray-600' }`} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > 步行 setCurrentAnimation('running')} className={`p-3 rounded-lg text-sm font-medium transition-all duration-200 ${ currentAnimation === 'running' ? 'bg-orange-500 text-white shadow-lg' : 'bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 border border-gray-200 dark:border-gray-600' }`} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > 跑步 setCurrentAnimation('jumping')} className={`p-3 rounded-lg text-sm font-medium transition-all duration-200 ${ currentAnimation === 'jumping' ? 'bg-orange-500 text-white shadow-lg' : 'bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 border border-gray-200 dark:border-gray-600' }`} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > 跳跃
{/* 视角控制 */}

视角控制

setAutoRotate(!autoRotate)} className={`w-full p-3 rounded-lg text-sm font-medium transition-all duration-200 flex items-center justify-center ${ autoRotate ? 'bg-blue-500 text-white shadow-lg' : 'bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 border border-gray-200 dark:border-gray-600' }`} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > {autoRotate ? '停止旋转' : '自动旋转'} setRotation(!rotation)} className={`w-full p-3 rounded-lg text-sm font-medium transition-all duration-200 flex items-center justify-center ${ rotation ? 'bg-green-500 text-white shadow-lg' : 'bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600 border border-gray-200 dark:border-gray-600' }`} whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > {rotation ? '禁用控制' : '启用控制'}
{/* 皮肤信息 */}

📋 皮肤信息

{texture.description && (

描述

{texture.description}

)}

收藏数

{texture.favorite_count || 0}

下载数

{texture.download_count || 0}

{texture.uploader && (

上传者

{texture.uploader.username}

)} {texture.created_at && (

上传时间

{new Date(texture.created_at).toLocaleDateString('zh-CN')}

)}
{/* 快捷键提示 */}

⌨️ 快捷键

空格 播放/暂停

1 静止

2 步行

3 跑步

4 跳跃

ESC 关闭

)}
); }