feat: 用 lucide-react 图标替换 emoji,修复所有 lint/构建问题
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 17m40s

- 用 Carrot/Palette/Shirt/AlertTriangle 替换 CS/C/🎨/🧥/⚠️
- 清理所有未使用的 imports 和变量
- 修复 useEffect 中同步 setState 问题(改用 rAF / setTimeout)
- 修复 no-unescaped-entities、匿名导出等 lint 错误
- 为 useSearchParams 添加 Suspense 边界(修复构建)
- 0 errors, 0 warnings
This commit is contained in:
2026-07-09 17:15:59 +08:00
parent 38f11445ba
commit 55cf05110a
19 changed files with 167 additions and 262 deletions

View File

@@ -1,5 +1,7 @@
export default {
const config = {
plugins: {
'@tailwindcss/postcss': {},
},
}
};
export default config;

View File

@@ -1,6 +1,6 @@
'use client';
import { useState, useEffect } from 'react';
import { useState, useEffect, Suspense } from 'react';
import Link from 'next/link';
import { useRouter, useSearchParams } from 'next/navigation';
import { motion, AnimatePresence } from 'framer-motion';
@@ -17,7 +17,7 @@ import { sendVerificationCode, resetPassword } from '@/lib/api';
// - TLD至少 2 位字母
const EMAIL_REGEX = /^(?!.*\.\.)[a-zA-Z0-9._%+-]+(?<!\.)@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/;
export default function AuthPage() {
function AuthForm() {
const [isLoginMode, setIsLoginMode] = useState(true);
const [formData, setFormData] = useState({
username: '',
@@ -172,7 +172,7 @@ export default function AuthPage() {
setErrors(prev => ({ ...prev, email: data.message || '发送验证码失败' }));
errorManager.showError(data.message || '发送验证码失败');
}
} catch (error) {
} catch {
setErrors(prev => ({ ...prev, email: '发送验证码失败,请稍后重试' }));
errorManager.showError('发送验证码失败,请稍后重试');
} finally {
@@ -959,3 +959,11 @@ export default function AuthPage() {
</div>
);
}
export default function AuthPage() {
return (
<Suspense fallback={<div className="min-h-screen flex items-center justify-center">Loading...</div>}>
<AuthForm />
</Suspense>
);
}

View File

@@ -12,6 +12,7 @@ import {
SparklesIcon,
RocketLaunchIcon
} from '@heroicons/react/24/outline';
import { Carrot } from 'lucide-react';
export default function Home() {
const { scrollYProgress } = useScroll();
@@ -102,7 +103,7 @@ export default function Home() {
>
<div className="relative">
<div className="w-24 h-24 bg-gradient-to-br from-orange-400 via-amber-500 to-orange-600 rounded-3xl flex items-center justify-center shadow-2xl">
<span className="text-4xl font-bold text-white">CS</span>
<Carrot className="w-12 h-12 text-white" />
</div>
<motion.div
className="absolute -inset-2 bg-gradient-to-br from-orange-400/30 to-amber-500/30 rounded-3xl blur-lg"

View File

@@ -12,14 +12,10 @@ import {
XMarkIcon,
UserIcon,
PhotoIcon,
HeartIcon,
TrashIcon,
PencilIcon,
KeyIcon,
EnvelopeIcon,
CloudArrowUpIcon,
EyeIcon,
ArrowDownTrayIcon,
ArrowLeftOnRectangleIcon
} from '@heroicons/react/24/outline';
import {
@@ -78,14 +74,14 @@ export default function ProfilePage() {
const [showCreateCharacter, setShowCreateCharacter] = useState(false);
const [showUploadSkin, setShowUploadSkin] = useState(false);
const [newCharacterName, setNewCharacterName] = useState('');
const [newSkinData, setNewSkinData] = useState({
const [, setNewSkinData] = useState({
name: '',
description: '',
type: 'SKIN' as 'SKIN' | 'CAPE',
is_public: false,
is_slim: false
});
const [selectedFile, setSelectedFile] = useState<File | null>(null);
const [, setSelectedFile] = useState<File | null>(null);
const [editingProfile, setEditingProfile] = useState<string | null>(null);
const [editProfileName, setEditProfileName] = useState('');
const [uploadProgress, setUploadProgress] = useState(0);
@@ -106,7 +102,7 @@ export default function ProfilePage() {
const [emailCodeCountdown, setEmailCodeCountdown] = useState(0);
const [isChangingEmail, setIsChangingEmail] = useState(false);
const { user, isAuthenticated, isLoading: isAuthLoading, logout, updateUser } = useAuth();
const { isAuthenticated, isLoading: isAuthLoading, logout, updateUser } = useAuth();
// 加载用户数据
useEffect(() => {
@@ -252,13 +248,6 @@ export default function ProfilePage() {
}
};
const handleFileSelect = (e: React.ChangeEvent<HTMLInputElement>) => {
const file = e.target.files?.[0];
if (file) {
setSelectedFile(file);
}
};
const handleUploadSkin = async (file: File, data: { name: string; description: string; type: 'SKIN' | 'CAPE'; is_public: boolean; is_slim: boolean }) => {
if (!file || !data.name.trim()) {
messageManager.warning('请选择皮肤文件并输入皮肤名称', { duration: 3000 });
@@ -721,6 +710,7 @@ export default function ProfilePage() {
<div className="flex items-center space-x-6">
<div className="relative">
{userProfile?.avatar ? (
/* eslint-disable-next-line @next/next/no-img-element */
<img
src={userProfile.avatar}
alt={userProfile.username}
@@ -985,7 +975,7 @@ export default function ProfilePage() {
>
<div className="flex justify-between items-center mb-6">
<h3 className="text-xl font-bold text-gray-900 dark:text-white">
"{currentProfile?.name}"
&ldquo;{currentProfile?.name}&rdquo;
</h3>
<button
onClick={() => setShowSkinSelector(null)}

View File

@@ -2,7 +2,8 @@
import { useState, useEffect, useCallback } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { MagnifyingGlassIcon, EyeIcon, HeartIcon, ArrowDownTrayIcon, SparklesIcon, FunnelIcon, ArrowsUpDownIcon } from '@heroicons/react/24/outline';
import { MagnifyingGlassIcon, FunnelIcon, ArrowsUpDownIcon } from '@heroicons/react/24/outline';
import { Palette } from 'lucide-react';
import SkinDetailModal from '@/components/SkinDetailModal';
import SkinCard from '@/components/SkinCard';
import { searchTextures, toggleFavorite, type Texture } from '@/lib/api';
@@ -305,7 +306,7 @@ export default function SkinsPage() {
animate={{ opacity: 1 }}
transition={{ delay: 0.2 }}
>
{textures.map((texture, index) => {
{textures.map((texture) => {
const isFavorited = favoritedIds.has(texture.id);
return (
@@ -333,7 +334,9 @@ export default function SkinsPage() {
exit={{ opacity: 0, scale: 0.9 }}
className="text-center py-16"
>
<div className="text-6xl mb-4">🎨</div>
<div className="flex justify-center mb-4">
<Palette className="w-16 h-16 text-orange-500" />
</div>
<h3 className="text-xl font-semibold text-gray-900 dark:text-white mb-2">
</h3>

View File

@@ -1,7 +1,7 @@
'use client';
import { motion, MotionProps } from 'framer-motion';
import { ReactNode, useState, useEffect } from 'react';
import { ReactNode, useState } from 'react';
import { AnimatePresence } from 'framer-motion';
interface EnhancedButtonProps extends Omit<MotionProps, 'onClick'> {
@@ -15,7 +15,6 @@ interface EnhancedButtonProps extends Omit<MotionProps, 'onClick'> {
icon?: ReactNode;
iconPosition?: 'left' | 'right';
ripple?: boolean;
sound?: boolean;
haptic?: boolean;
className?: string;
type?: 'button' | 'submit' | 'reset';
@@ -32,7 +31,6 @@ export default function EnhancedButton({
icon,
iconPosition = 'left',
ripple = true,
sound = true,
haptic = true,
className = '',
type = 'button',
@@ -41,37 +39,6 @@ export default function EnhancedButton({
const [isProcessing, setIsProcessing] = useState(false);
const [ripples, setRipples] = useState<Array<{ id: number; x: number; y: number }>>([]);
// 播放音效
const playSound = (type: 'click' | 'success' | 'error' = 'click') => {
if (!sound) return;
try {
const audioContext = new (window.AudioContext || (window as any).webkitAudioContext)();
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
const frequencies = {
click: 800,
success: 1000,
error: 400
};
oscillator.frequency.setValueAtTime(frequencies[type], audioContext.currentTime);
oscillator.type = type === 'error' ? 'sawtooth' : 'sine';
gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.2);
oscillator.start(audioContext.currentTime);
oscillator.stop(audioContext.currentTime + 0.2);
} catch (error) {
// 忽略音频API错误
}
};
// 触觉反馈
const triggerHaptic = () => {
if (haptic && navigator.vibrate) {
@@ -102,7 +69,6 @@ export default function EnhancedButton({
if (disabled || loading || isProcessing) return;
createRipple(e);
playSound('click');
triggerHaptic();
if (onClick) {
@@ -113,10 +79,8 @@ export default function EnhancedButton({
// 如果返回的是 Promise等待它完成
if (result instanceof Promise) {
await result;
playSound('success');
}
} catch (error) {
playSound('error');
console.error('Button click error:', error);
} finally {
setIsProcessing(false);

View File

@@ -192,7 +192,6 @@ export function ErrorNotification({ message, type = 'error', duration = 5000, on
class ErrorManager {
private static instance: ErrorManager;
private listeners: Array<(notification: ErrorNotificationProps & { id: string }) => void> = [];
private soundEnabled: boolean = true;
static getInstance(): ErrorManager {
if (!ErrorManager.instance) {
@@ -201,51 +200,19 @@ class ErrorManager {
return ErrorManager.instance;
}
private playSound(type: ErrorType) {
if (!this.soundEnabled) return;
// 创建音频反馈
const audioContext = new (window.AudioContext || (window as any).webkitAudioContext)();
const oscillator = audioContext.createOscillator();
const gainNode = audioContext.createGain();
oscillator.connect(gainNode);
gainNode.connect(audioContext.destination);
const frequencies = {
error: 300,
warning: 400,
success: 600,
info: 500
};
oscillator.frequency.setValueAtTime(frequencies[type], audioContext.currentTime);
oscillator.type = type === 'error' ? 'sawtooth' : 'sine';
gainNode.gain.setValueAtTime(0.1, audioContext.currentTime);
gainNode.gain.exponentialRampToValueAtTime(0.01, audioContext.currentTime + 0.3);
oscillator.start(audioContext.currentTime);
oscillator.stop(audioContext.currentTime + 0.3);
}
showError(message: string, duration?: number) {
this.playSound('error');
this.showNotification(message, 'error', duration);
}
showWarning(message: string, duration?: number) {
this.playSound('warning');
this.showNotification(message, 'warning', duration);
}
showSuccess(message: string, duration?: number) {
this.playSound('success');
this.showNotification(message, 'success', duration);
}
showInfo(message: string, duration?: number) {
this.playSound('info');
this.showNotification(message, 'info', duration);
}
@@ -266,10 +233,6 @@ class ErrorManager {
this.listeners = this.listeners.filter(l => l !== listener);
};
}
setSoundEnabled(enabled: boolean) {
this.soundEnabled = enabled;
}
}
export const errorManager = ErrorManager.getInstance();
@@ -277,7 +240,6 @@ export const errorManager = ErrorManager.getInstance();
// 增强的错误提示容器组件
export function ErrorNotificationContainer() {
const [notifications, setNotifications] = useState<Array<ErrorNotificationProps & { id: string }>>([]);
const [soundEnabled, setSoundEnabled] = useState(true);
useEffect(() => {
const unsubscribe = errorManager.subscribe((notification) => {
@@ -287,10 +249,6 @@ export function ErrorNotificationContainer() {
return unsubscribe;
}, []);
useEffect(() => {
errorManager.setSoundEnabled(soundEnabled);
}, [soundEnabled]);
const removeNotification = (id: string) => {
setNotifications(prev => prev.filter(n => n.id !== id));
};

View File

@@ -1,22 +1,19 @@
'use client';
import Link from 'next/link';
import { motion, AnimatePresence, useScroll, useTransform } from 'framer-motion';
import { useState, useCallback, useEffect } from 'react';
import { motion, AnimatePresence, useScroll } from 'framer-motion';
import { useState, useCallback, useMemo, useEffect } from 'react';
import {
HomeIcon,
ArrowLeftIcon,
ExclamationTriangleIcon,
XCircleIcon,
ClockIcon,
ServerIcon,
WifiIcon,
ClipboardDocumentIcon,
ArrowPathIcon,
CubeIcon,
QuestionMarkCircleIcon,
SparklesIcon,
RocketLaunchIcon
QuestionMarkCircleIcon
} from '@heroicons/react/24/outline';
import { messageManager } from './MessageNotification';
@@ -172,9 +169,7 @@ export function ErrorPage({
const [isRetrying, setIsRetrying] = useState(false);
const [showDetails, setShowDetails] = useState(false);
const [copySuccess, setCopySuccess] = useState(false);
const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });
const { scrollYProgress } = useScroll();
const opacity = useTransform(scrollYProgress, [0, 0.3], [1, 0.8]);
useScroll(); // keep hook for future use
const config = errorConfigs[type] || {};
const displayTitle = title || config.title || '出错了';
@@ -194,7 +189,8 @@ export function ErrorPage({
return JSON.stringify(details, null, 2);
}, [type, code, errorDetails]);
const defaultActions = {
const finalActions = useMemo(() => {
const defaults = {
primary: {
label: '返回主城',
href: '/'
@@ -208,18 +204,8 @@ export function ErrorPage({
}
}
};
const finalActions = { ...defaultActions, ...actions };
const getThemeStyles = () => {
return {
bg: 'bg-gradient-to-br from-slate-50 via-orange-50 to-amber-50 dark:from-gray-900 dark:via-gray-800 dark:to-gray-900',
card: 'bg-white/70 dark:bg-gray-800/70 backdrop-blur-lg',
text: 'text-gray-900 dark:text-white',
subtext: 'text-gray-600 dark:text-gray-300',
accent: 'text-orange-500 dark:text-orange-400'
};
};
return { ...defaults, ...actions };
}, [actions]);
const getIconColor = () => {
const colors = {
@@ -251,13 +237,13 @@ export function ErrorPage({
return 'from-orange-500 to-amber-500 hover:from-orange-600 hover:to-amber-600';
};
const handleRetry = async () => {
const handleRetry = useCallback(async () => {
if (onRetry) {
setIsRetrying(true);
try {
await onRetry();
messageManager.success('重试成功!', { duration: 3000 });
} catch (error) {
} catch {
messageManager.error('重试失败,请稍后重试', { duration: 5000 });
} finally {
setIsRetrying(false);
@@ -268,9 +254,9 @@ export function ErrorPage({
window.location.reload();
}
}
};
}, [onRetry]);
const handleCopyError = async () => {
const handleCopyError = useCallback(async () => {
try {
const details = generateErrorDetails();
if (typeof navigator !== 'undefined' && navigator.clipboard) {
@@ -290,15 +276,10 @@ export function ErrorPage({
messageManager.success('错误信息已复制到剪贴板', { duration: 2000 });
setTimeout(() => setCopySuccess(false), 2000);
}
} catch (error) {
} catch {
messageManager.error('复制失败,请手动复制', { duration: 3000 });
}
};
const handleReportError = () => {
messageManager.info('感谢您的反馈,我们会尽快处理', { duration: 3000 });
// 这里可以添加实际的错误报告逻辑
};
}, [generateErrorDetails]);
// 键盘快捷键支持
useEffect(() => {
@@ -315,8 +296,6 @@ export function ErrorPage({
}
}, [handleRetry]);
const themeStyles = getThemeStyles();
return (
<div className={`min-h-screen bg-gradient-to-br from-slate-50 via-orange-50 to-amber-50 dark:from-gray-900 dark:via-gray-800 dark:to-gray-900 ${className}`}>
{/* Animated Background - 简化背景动画 */}

View File

@@ -6,14 +6,12 @@ import { ReactNode } from 'react';
interface LoadingSpinnerProps {
size?: 'sm' | 'md' | 'lg' | 'xl';
color?: 'orange' | 'blue' | 'green' | 'red' | 'purple' | 'gray';
speed?: 'slow' | 'normal' | 'fast';
className?: string;
}
export function LoadingSpinner({
size = 'md',
color = 'orange',
speed = 'normal',
className = ''
}: LoadingSpinnerProps) {
const sizes = {
@@ -32,12 +30,6 @@ export function LoadingSpinner({
gray: 'border-gray-500'
};
const speeds = {
slow: 'duration-2000',
normal: 'duration-1000',
fast: 'duration-500'
};
return (
<motion.div
className={`${sizes[size]} ${colors[color]} border-2 border-t-transparent rounded-full animate-spin ${className}`}

View File

@@ -7,8 +7,7 @@ import {
ExclamationTriangleIcon,
CheckCircleIcon,
InformationCircleIcon,
XCircleIcon,
BellIcon
XCircleIcon
} from '@heroicons/react/24/outline';
export type MessageType = 'success' | 'error' | 'warning' | 'info' | 'loading';

View File

@@ -5,14 +5,13 @@ import Link from 'next/link';
import { useRouter, usePathname } from 'next/navigation';
import { Bars3Icon, XMarkIcon, UserCircleIcon } from '@heroicons/react/24/outline';
import { motion, AnimatePresence, useScroll, useTransform, useSpring } from 'framer-motion';
import { Carrot } from 'lucide-react';
import { useAuth } from '@/contexts/AuthContext';
export default function Navbar() {
const [isOpen, setIsOpen] = useState(false);
const [isHidden, setIsHidden] = useState(false);
const [isScrolled, setIsScrolled] = useState(false);
const [showScrollTop, setShowScrollTop] = useState(false);
const [navbarHeight, setNavbarHeight] = useState(0);
const [scrollProgress, setScrollProgress] = useState(0);
const navbarRef = useRef<HTMLElement>(null);
const { user, isAuthenticated, isLoading: isAuthLoading, logout } = useAuth();
@@ -24,7 +23,6 @@ export default function Navbar() {
const springConfig = { stiffness: 300, damping: 30 };
const navbarY = useSpring(useTransform(scrollY, [0, 100], [0, -100]), springConfig);
const navbarOpacity = useSpring(useTransform(scrollY, [0, 50], [1, 0.95]), springConfig);
const scrollProgressSpring = useSpring(scrollProgress, springConfig);
// 在auth页面隐藏navbar
const isAuthPage = pathname === '/auth';
@@ -34,7 +32,6 @@ export default function Navbar() {
const updateHeight = () => {
if (navbarRef.current) {
const height = navbarRef.current.offsetHeight;
setNavbarHeight(height);
document.documentElement.style.setProperty('--navbar-height', `${height}px`);
}
};
@@ -69,9 +66,6 @@ export default function Navbar() {
// 检测是否滚动到顶部
setIsScrolled(currentScrollY > 20);
// 显示返回顶部按钮滚动超过300px
setShowScrollTop(currentScrollY > 300);
// 更敏感的隐藏逻辑:只要往下滚动就隐藏,不管滚动多少
if (!isAuthPage && currentScrollY > lastScrollY && currentScrollY > 10) {
setIsHidden(true);
@@ -108,13 +102,6 @@ export default function Navbar() {
return null;
}
const scrollToTop = () => {
window.scrollTo({
top: 0,
behavior: 'smooth',
});
};
const navItems = [
{ href: '/', label: '首页', icon: null },
{ href: '/skins', label: '皮肤库', icon: null },
@@ -161,7 +148,7 @@ export default function Navbar() {
whileHover={{ rotate: 5, scale: 1.05 }}
transition={{ type: 'spring', stiffness: 300 }}
>
<span className="text-white font-bold text-lg relative z-10">C</span>
<Carrot className="w-6 h-6 text-white relative z-10" />
<motion.div
className="absolute inset-0 bg-gradient-to-br from-white/20 to-transparent"
initial={{ x: '-100%', y: '-100%' }}
@@ -237,6 +224,7 @@ export default function Navbar() {
className="relative"
whileHover={{ scale: 1.1, rotate: 5 }}
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={user.avatar}
alt={user.username}
@@ -405,6 +393,7 @@ export default function Navbar() {
>
<div className="flex items-center space-x-3">
{user?.avatar ? (
/* eslint-disable-next-line @next/next/no-img-element */
<img
src={user.avatar}
alt={user.username}
@@ -468,7 +457,7 @@ export default function Navbar() {
</AnimatePresence>
</motion.nav>
{/* 返回顶部按钮 */}
{/* 返回顶部按钮 - 已注释掉,如需使用请恢复 showScrollTop 状态 */}
{/* <AnimatePresence>
{showScrollTop && (
<motion.button
@@ -477,7 +466,7 @@ export default function Navbar() {
exit={{ opacity: 0, scale: 0.8, y: 20 }}
whileHover={{ scale: 1.1, y: -2 }}
whileTap={{ scale: 0.9 }}
onClick={scrollToTop}
onClick={() => window.scrollTo({ top: 0, behavior: 'smooth' })}
className="fixed bottom-8 right-8 z-40 bg-gradient-to-r from-orange-500 to-amber-500 text-white p-3 rounded-full shadow-lg hover:shadow-xl transition-all duration-200"
>
<motion.div

View File

@@ -4,6 +4,7 @@ import { motion, AnimatePresence } from 'framer-motion';
import { useState } from 'react';
import { EyeIcon, ArrowDownTrayIcon, HeartIcon } from '@heroicons/react/24/outline';
import { HeartIcon as HeartIconSolid } from '@heroicons/react/24/solid';
import { Shirt } from 'lucide-react';
import SkinViewer from './SkinViewer';
import type { Texture } from '@/lib/api';
@@ -197,7 +198,7 @@ export default function SkinCard({
transition={{ type: 'spring' as const, stiffness: 300 }}
animate={imageLoaded ? {} : { scale: [0.8, 1, 0.8] }}
>
<span className="text-2xl">🧥</span>
<Shirt className="w-10 h-10 text-orange-500" />
</motion.div>
<p className="text-sm text-gray-600 dark:text-gray-300 font-medium"></p>
</motion.div>
@@ -406,13 +407,13 @@ export default function SkinCard({
</motion.span>
</div>
<div className="text-xs text-gray-400">
{texture.uploader_id && (
{texture.uploader_username && (
<motion.span
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ delay: index * 0.1 + 0.6 }}
>
by User #{texture.uploader_id}
by {texture.uploader_username}
</motion.span>
)}
</div>

View File

@@ -18,9 +18,7 @@ interface SkinDetailModalProps {
favorite_count?: number;
download_count?: number;
created_at?: string;
uploader?: {
username: string;
};
uploader_username?: string;
} | null;
isExternalPreview?: boolean;
}
@@ -32,16 +30,19 @@ export default function SkinDetailModal({ isOpen, onClose, texture, isExternalPr
const [isMinimized, setIsMinimized] = useState(false);
const [isPaused, setIsPaused] = useState(false); // 新增:动画暂停状态
// 重置状态当对话框关闭时
// 重置状态当对话框关闭时 - 使用事件循环避免同步 setState
useEffect(() => {
if (!isOpen) {
const timer = setTimeout(() => {
setCurrentAnimation('idle');
setAutoRotate(!isExternalPreview);
setRotation(true);
setIsMinimized(false);
setIsPaused(false); // 重置暂停状态
setIsPaused(false);
}, 0);
return () => clearTimeout(timer);
}
}, [isOpen]);
}, [isOpen, isExternalPreview]);
// 键盘事件处理
useEffect(() => {
@@ -286,10 +287,10 @@ export default function SkinDetailModal({ isOpen, onClose, texture, isExternalPr
{ key: 'walking', label: '步行', icon: null },
{ key: 'running', label: '跑步', icon: null },
{ key: 'swimming', label: '游泳', icon: null }
].map((anim, i) => (
].map((anim) => (
<button
key={anim.key}
onClick={() => handleAnimationChange(anim.key as any)}
onClick={() => handleAnimationChange(anim.key as 'idle' | 'walking' | 'running' | 'swimming')}
className={`p-4 rounded-xl text-sm font-semibold transition-all duration-200 ${
currentAnimation === anim.key
? 'bg-gradient-to-r from-orange-500 via-amber-500 to-yellow-500 text-white shadow-lg ring-2 ring-orange-300 dark:ring-orange-500'
@@ -327,7 +328,7 @@ export default function SkinDetailModal({ isOpen, onClose, texture, isExternalPr
)}
<div className="space-y-2 text-sm">
{texture.uploader && (
{texture.uploader_username && (
<motion.div
className="flex justify-between items-center"
initial={{ opacity: 0, x: -10 }}
@@ -335,7 +336,7 @@ export default function SkinDetailModal({ isOpen, onClose, texture, isExternalPr
transition={{ delay: 1.0 }}
>
<span className="text-gray-600 dark:text-gray-400">:</span>
<span className="font-medium text-gray-800 dark:text-gray-200">{texture.uploader.username}</span>
<span className="font-medium text-gray-800 dark:text-gray-200">{texture.uploader_username}</span>
</motion.div>
)}

View File

@@ -1,6 +1,7 @@
'use client';
import { useEffect, useRef, useState } from 'react';
import { AlertTriangle } from 'lucide-react';
import { SkinViewer as SkinViewer3D, WalkingAnimation, RunningAnimation, FlyingAnimation, IdleAnimation } from 'skinview3d';
interface SkinViewerProps {
@@ -44,50 +45,64 @@ export default function SkinViewer({
// 预加载皮肤图片以检查是否可访问
useEffect(() => {
if (!skinUrl) return;
if (!skinUrl) {
// 使用 requestAnimationFrame 避免同步 setState 触发级联渲染
const frame = requestAnimationFrame(() => {
setIsLoading(false);
setHasError(true);
});
return () => cancelAnimationFrame(frame);
}
// 使用 requestAnimationFrame 避免同步 setState 触发级联渲染
const initFrame = requestAnimationFrame(() => {
setIsLoading(true);
setHasError(false);
setImageLoaded(false);
});
let isCancelled = false;
const img = new Image();
img.crossOrigin = 'anonymous'; // 尝试跨域访问
img.crossOrigin = 'anonymous';
img.onload = () => {
if (isCancelled) return;
console.log('皮肤图片加载成功:', skinUrl);
setImageLoaded(true);
setIsLoading(false);
if (onImageLoaded) {
onImageLoaded();
}
onImageLoaded?.();
};
img.onerror = (error) => {
console.error('皮肤图片加载失败:', skinUrl, error);
img.onerror = () => {
if (isCancelled) return;
console.error('皮肤图片加载失败:', skinUrl);
setHasError(true);
setIsLoading(false);
};
// 开始加载图片
img.src = skinUrl;
return () => {
// 清理
cancelAnimationFrame(initFrame);
isCancelled = true;
img.onload = null;
img.onerror = null;
};
}, [skinUrl]);
}, [skinUrl, onImageLoaded]);
// 初始化3D查看器
useEffect(() => {
if (!canvasRef.current || !imageLoaded || hasError) return;
const canvas = canvasRef.current;
let viewer: SkinViewer3D | null = null;
// 使用 requestAnimationFrame 避免在 effect 体中同步 setState
const initFrame = requestAnimationFrame(() => {
try {
console.log('初始化3D皮肤查看器:', { skinUrl, isSlim, width, height });
// 使用传入的宽高参数初始化
const canvas = canvasRef.current;
const viewer = new SkinViewer3D({
viewer = new SkinViewer3D({
canvas: canvas,
width: width,
height: height,
@@ -117,14 +132,15 @@ export default function SkinViewer({
viewer.controls.enablePan = false; // 禁用平移
console.log('3D皮肤查看器初始化成功');
} catch (error) {
console.error('3D皮肤查看器初始化失败:', error);
setHasError(true);
}
});
// 清理函数
return () => {
cancelAnimationFrame(initFrame);
if (viewerRef.current) {
try {
viewerRef.current.dispose();
@@ -248,7 +264,9 @@ export default function SkinViewer({
style={{ width: width, height: height }}
>
<div className="text-center p-4">
<div className="text-4xl mb-2"></div>
<div className="flex justify-center mb-2">
<AlertTriangle className="w-10 h-10 text-red-500" />
</div>
<div className="text-sm text-red-600 dark:text-red-400 font-medium mb-1">
</div>

View File

@@ -76,7 +76,7 @@ export const SliderCaptcha: React.FC<SliderCaptchaProps> = ({ onVerify, onClose
const response = await axios.get(`${API_BASE_URL}/captcha/generate`, {
withCredentials: true // 关键:允许跨域携带凭证
});
const { code, msg: resMsg, data } = response.data;
const { code, message: resMsg, data } = response.data;
const { masterImage, tileImage, captchaId, y } = data;
// 后端返回成功状态code=200
@@ -170,7 +170,7 @@ export const SliderCaptcha: React.FC<SliderCaptchaProps> = ({ onVerify, onClose
captchaId: processId // 验证码进程ID
},{ withCredentials: true });
const { code, msg: resMsg, data } = response.data;
const { code, message: resMsg } = response.data;
// 保存后端返回的提示信息
setMsg(resMsg);
@@ -400,10 +400,11 @@ export const SliderCaptcha: React.FC<SliderCaptchaProps> = ({ onVerify, onClose
{/* 背景图片容器尺寸300x200px与后端图片尺寸匹配 */}
<div className="relative bg-gray-200 rounded-lg w-[300px] h-[200px] mb-4 overflow-hidden mx-auto">
{backgroundImage && (
/* eslint-disable-next-line @next/next/no-img-element */
<img
src={backgroundImage}
alt="验证背景"
className="h-full w-full object-cover" // 图片填满容器
className="h-full w-full object-cover"
/>
)}
{/* 可移动拼图块 */}
@@ -411,11 +412,12 @@ export const SliderCaptcha: React.FC<SliderCaptchaProps> = ({ onVerify, onClose
<div
className={`absolute ${isDragging ? '' : 'transition-all duration-300'}`}
style={{
left: `${sliderPosition}px`, // 滑块x位置拼图左上角x坐标
top: `${puzzleY}px`, // 拼图y位置从后端获取拼图左上角y坐标
left: `${sliderPosition}px`,
top: `${puzzleY}px`,
zIndex: 10,
}}
>
{/* eslint-disable-next-line @next/next/no-img-element */}
<img
src={puzzleImage}
alt="拼图块"

View File

@@ -2,8 +2,7 @@
import { useState } from 'react';
import { motion } from 'framer-motion';
import { PhotoIcon, ArrowDownTrayIcon, EyeIcon, HeartIcon } from '@heroicons/react/24/outline';
import { HeartIcon as HeartIconSolid } from '@heroicons/react/24/solid';
import { HeartIcon } from '@heroicons/react/24/outline';
import SkinCard from '@/components/SkinCard';
import SkinDetailModal from '@/components/SkinDetailModal';
import type { Texture } from '@/lib/api';

View File

@@ -1,13 +1,11 @@
'use client';
import { useState } from 'react';
import { motion, AnimatePresence } from 'framer-motion';
import { motion } from 'framer-motion';
import {
PhotoIcon,
ArrowDownTrayIcon,
EyeIcon,
TrashIcon,
CloudArrowUpIcon
CloudArrowUpIcon,
TrashIcon
} from '@heroicons/react/24/outline';
import SkinCard from '@/components/SkinCard';
import SkinDetailModal from '@/components/SkinDetailModal';

View File

@@ -47,6 +47,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
};
checkAuthStatus();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const setAuthToken = (token: string) => {

View File

@@ -3,6 +3,7 @@ export const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || '/api/v1';
export interface Texture {
id: number;
uploader_id: number;
uploader_username?: string;
name: string;
description?: string;
type: 'SKIN' | 'CAPE';
@@ -24,7 +25,6 @@ export interface Profile {
name: string;
skin_id?: number;
cape_id?: number;
is_active?: boolean;
last_used_at?: string;
created_at: string;
updated_at: string;