'use client'; import { motion } from 'framer-motion'; import { UserIcon, PencilIcon, TrashIcon, CheckIcon } from '@heroicons/react/24/outline'; import SkinViewer from '@/components/SkinViewer'; import type { Profile } from '@/lib/api'; interface CharacterCardProps { profile: Profile; skinUrl?: string; isSlim?: boolean; isEditing?: boolean; editName?: string; onEdit: (uuid: string, currentName: string) => void; onSave: (uuid: string) => void; onCancel: () => void; onDelete: (uuid: string) => void; onSetActive: (uuid: string) => void; onSelectSkin: (uuid: string) => void; onEditNameChange: (name: string) => void; } export default function CharacterCard({ profile, skinUrl, isSlim, isEditing, editName, onEdit, onSave, onCancel, onDelete, onSetActive, onSelectSkin, onEditNameChange }: CharacterCardProps) { return (
{isEditing ? ( onEditNameChange(e.target.value)} className="text-lg font-semibold bg-transparent border-b border-orange-500 focus:outline-none text-gray-900 dark:text-white flex-1 mr-2" onBlur={() => onSave(profile.uuid)} onKeyPress={(e) => e.key === 'Enter' && onSave(profile.uuid)} autoFocus /> ) : (

{profile.name}

)} {profile.is_active && ( 当前使用 )}
{skinUrl ? ( ) : ( )} {/* 皮肤选择按钮 */} onSelectSkin(profile.uuid)} className="absolute bottom-2 right-2 bg-gradient-to-r from-orange-500 to-amber-500 text-white p-2 rounded-full shadow-lg" whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.9 }} title="选择皮肤" >
{/* 操作按钮 */}
{!profile.is_active && ( onSetActive(profile.uuid)} className="flex-1 bg-gradient-to-r from-green-500 to-emerald-500 hover:from-green-600 hover:to-emerald-600 text-white text-sm py-2 px-3 rounded-lg transition-all duration-200" whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > 使用 )} {isEditing ? ( <> onSave(profile.uuid)} className="flex-1 bg-gradient-to-r from-green-500 to-emerald-500 hover:from-green-600 hover:to-emerald-600 text-white text-sm py-2 px-3 rounded-lg transition-all duration-200" whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > 保存 取消 ) : ( <> onEdit(profile.uuid, profile.name)} className="flex-1 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700 text-sm py-2 px-3 rounded-lg transition-all duration-200" whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > 编辑 onDelete(profile.uuid)} className="px-3 py-2 border border-red-500 text-red-500 hover:bg-red-500 hover:text-white rounded-lg transition-all duration-200" whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }} > )}
); }