feat: 用 lucide-react 图标替换 emoji,修复所有 lint/构建问题
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 17m40s
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:
@@ -1,5 +1,7 @@
|
|||||||
export default {
|
const config = {
|
||||||
plugins: {
|
plugins: {
|
||||||
'@tailwindcss/postcss': {},
|
'@tailwindcss/postcss': {},
|
||||||
},
|
},
|
||||||
}
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState, useEffect } from 'react';
|
import { useState, useEffect, Suspense } from 'react';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { useRouter, useSearchParams } from 'next/navigation';
|
import { useRouter, useSearchParams } from 'next/navigation';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
@@ -17,7 +17,7 @@ import { sendVerificationCode, resetPassword } from '@/lib/api';
|
|||||||
// - TLD:至少 2 位字母
|
// - 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,}$/;
|
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 [isLoginMode, setIsLoginMode] = useState(true);
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
username: '',
|
username: '',
|
||||||
@@ -172,7 +172,7 @@ export default function AuthPage() {
|
|||||||
setErrors(prev => ({ ...prev, email: data.message || '发送验证码失败' }));
|
setErrors(prev => ({ ...prev, email: data.message || '发送验证码失败' }));
|
||||||
errorManager.showError(data.message || '发送验证码失败');
|
errorManager.showError(data.message || '发送验证码失败');
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
setErrors(prev => ({ ...prev, email: '发送验证码失败,请稍后重试' }));
|
setErrors(prev => ({ ...prev, email: '发送验证码失败,请稍后重试' }));
|
||||||
errorManager.showError('发送验证码失败,请稍后重试');
|
errorManager.showError('发送验证码失败,请稍后重试');
|
||||||
} finally {
|
} finally {
|
||||||
@@ -959,3 +959,11 @@ export default function AuthPage() {
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function AuthPage() {
|
||||||
|
return (
|
||||||
|
<Suspense fallback={<div className="min-h-screen flex items-center justify-center">Loading...</div>}>
|
||||||
|
<AuthForm />
|
||||||
|
</Suspense>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import {
|
|||||||
SparklesIcon,
|
SparklesIcon,
|
||||||
RocketLaunchIcon
|
RocketLaunchIcon
|
||||||
} from '@heroicons/react/24/outline';
|
} from '@heroicons/react/24/outline';
|
||||||
|
import { Carrot } from 'lucide-react';
|
||||||
|
|
||||||
export default function Home() {
|
export default function Home() {
|
||||||
const { scrollYProgress } = useScroll();
|
const { scrollYProgress } = useScroll();
|
||||||
@@ -102,7 +103,7 @@ export default function Home() {
|
|||||||
>
|
>
|
||||||
<div className="relative">
|
<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">
|
<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>
|
</div>
|
||||||
<motion.div
|
<motion.div
|
||||||
className="absolute -inset-2 bg-gradient-to-br from-orange-400/30 to-amber-500/30 rounded-3xl blur-lg"
|
className="absolute -inset-2 bg-gradient-to-br from-orange-400/30 to-amber-500/30 rounded-3xl blur-lg"
|
||||||
|
|||||||
@@ -12,14 +12,10 @@ import {
|
|||||||
XMarkIcon,
|
XMarkIcon,
|
||||||
UserIcon,
|
UserIcon,
|
||||||
PhotoIcon,
|
PhotoIcon,
|
||||||
HeartIcon,
|
|
||||||
TrashIcon,
|
|
||||||
PencilIcon,
|
PencilIcon,
|
||||||
KeyIcon,
|
KeyIcon,
|
||||||
EnvelopeIcon,
|
EnvelopeIcon,
|
||||||
CloudArrowUpIcon,
|
CloudArrowUpIcon,
|
||||||
EyeIcon,
|
|
||||||
ArrowDownTrayIcon,
|
|
||||||
ArrowLeftOnRectangleIcon
|
ArrowLeftOnRectangleIcon
|
||||||
} from '@heroicons/react/24/outline';
|
} from '@heroicons/react/24/outline';
|
||||||
import {
|
import {
|
||||||
@@ -78,14 +74,14 @@ export default function ProfilePage() {
|
|||||||
const [showCreateCharacter, setShowCreateCharacter] = useState(false);
|
const [showCreateCharacter, setShowCreateCharacter] = useState(false);
|
||||||
const [showUploadSkin, setShowUploadSkin] = useState(false);
|
const [showUploadSkin, setShowUploadSkin] = useState(false);
|
||||||
const [newCharacterName, setNewCharacterName] = useState('');
|
const [newCharacterName, setNewCharacterName] = useState('');
|
||||||
const [newSkinData, setNewSkinData] = useState({
|
const [, setNewSkinData] = useState({
|
||||||
name: '',
|
name: '',
|
||||||
description: '',
|
description: '',
|
||||||
type: 'SKIN' as 'SKIN' | 'CAPE',
|
type: 'SKIN' as 'SKIN' | 'CAPE',
|
||||||
is_public: false,
|
is_public: false,
|
||||||
is_slim: 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 [editingProfile, setEditingProfile] = useState<string | null>(null);
|
||||||
const [editProfileName, setEditProfileName] = useState('');
|
const [editProfileName, setEditProfileName] = useState('');
|
||||||
const [uploadProgress, setUploadProgress] = useState(0);
|
const [uploadProgress, setUploadProgress] = useState(0);
|
||||||
@@ -106,7 +102,7 @@ export default function ProfilePage() {
|
|||||||
const [emailCodeCountdown, setEmailCodeCountdown] = useState(0);
|
const [emailCodeCountdown, setEmailCodeCountdown] = useState(0);
|
||||||
const [isChangingEmail, setIsChangingEmail] = useState(false);
|
const [isChangingEmail, setIsChangingEmail] = useState(false);
|
||||||
|
|
||||||
const { user, isAuthenticated, isLoading: isAuthLoading, logout, updateUser } = useAuth();
|
const { isAuthenticated, isLoading: isAuthLoading, logout, updateUser } = useAuth();
|
||||||
|
|
||||||
// 加载用户数据
|
// 加载用户数据
|
||||||
useEffect(() => {
|
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 }) => {
|
const handleUploadSkin = async (file: File, data: { name: string; description: string; type: 'SKIN' | 'CAPE'; is_public: boolean; is_slim: boolean }) => {
|
||||||
if (!file || !data.name.trim()) {
|
if (!file || !data.name.trim()) {
|
||||||
messageManager.warning('请选择皮肤文件并输入皮肤名称', { duration: 3000 });
|
messageManager.warning('请选择皮肤文件并输入皮肤名称', { duration: 3000 });
|
||||||
@@ -721,6 +710,7 @@ export default function ProfilePage() {
|
|||||||
<div className="flex items-center space-x-6">
|
<div className="flex items-center space-x-6">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
{userProfile?.avatar ? (
|
{userProfile?.avatar ? (
|
||||||
|
/* eslint-disable-next-line @next/next/no-img-element */
|
||||||
<img
|
<img
|
||||||
src={userProfile.avatar}
|
src={userProfile.avatar}
|
||||||
alt={userProfile.username}
|
alt={userProfile.username}
|
||||||
@@ -985,7 +975,7 @@ export default function ProfilePage() {
|
|||||||
>
|
>
|
||||||
<div className="flex justify-between items-center mb-6">
|
<div className="flex justify-between items-center mb-6">
|
||||||
<h3 className="text-xl font-bold text-gray-900 dark:text-white">
|
<h3 className="text-xl font-bold text-gray-900 dark:text-white">
|
||||||
为角色 "{currentProfile?.name}" 选择皮肤
|
为角色 “{currentProfile?.name}” 选择皮肤
|
||||||
</h3>
|
</h3>
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowSkinSelector(null)}
|
onClick={() => setShowSkinSelector(null)}
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
import { useState, useEffect, useCallback } from 'react';
|
import { useState, useEffect, useCallback } from 'react';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
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 SkinDetailModal from '@/components/SkinDetailModal';
|
||||||
import SkinCard from '@/components/SkinCard';
|
import SkinCard from '@/components/SkinCard';
|
||||||
import { searchTextures, toggleFavorite, type Texture } from '@/lib/api';
|
import { searchTextures, toggleFavorite, type Texture } from '@/lib/api';
|
||||||
@@ -305,7 +306,7 @@ export default function SkinsPage() {
|
|||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
transition={{ delay: 0.2 }}
|
transition={{ delay: 0.2 }}
|
||||||
>
|
>
|
||||||
{textures.map((texture, index) => {
|
{textures.map((texture) => {
|
||||||
const isFavorited = favoritedIds.has(texture.id);
|
const isFavorited = favoritedIds.has(texture.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -333,7 +334,9 @@ export default function SkinsPage() {
|
|||||||
exit={{ opacity: 0, scale: 0.9 }}
|
exit={{ opacity: 0, scale: 0.9 }}
|
||||||
className="text-center py-16"
|
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 className="text-xl font-semibold text-gray-900 dark:text-white mb-2">
|
||||||
暂无材质
|
暂无材质
|
||||||
</h3>
|
</h3>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { motion, MotionProps } from 'framer-motion';
|
import { motion, MotionProps } from 'framer-motion';
|
||||||
import { ReactNode, useState, useEffect } from 'react';
|
import { ReactNode, useState } from 'react';
|
||||||
import { AnimatePresence } from 'framer-motion';
|
import { AnimatePresence } from 'framer-motion';
|
||||||
|
|
||||||
interface EnhancedButtonProps extends Omit<MotionProps, 'onClick'> {
|
interface EnhancedButtonProps extends Omit<MotionProps, 'onClick'> {
|
||||||
@@ -15,7 +15,6 @@ interface EnhancedButtonProps extends Omit<MotionProps, 'onClick'> {
|
|||||||
icon?: ReactNode;
|
icon?: ReactNode;
|
||||||
iconPosition?: 'left' | 'right';
|
iconPosition?: 'left' | 'right';
|
||||||
ripple?: boolean;
|
ripple?: boolean;
|
||||||
sound?: boolean;
|
|
||||||
haptic?: boolean;
|
haptic?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
type?: 'button' | 'submit' | 'reset';
|
type?: 'button' | 'submit' | 'reset';
|
||||||
@@ -32,7 +31,6 @@ export default function EnhancedButton({
|
|||||||
icon,
|
icon,
|
||||||
iconPosition = 'left',
|
iconPosition = 'left',
|
||||||
ripple = true,
|
ripple = true,
|
||||||
sound = true,
|
|
||||||
haptic = true,
|
haptic = true,
|
||||||
className = '',
|
className = '',
|
||||||
type = 'button',
|
type = 'button',
|
||||||
@@ -41,37 +39,6 @@ export default function EnhancedButton({
|
|||||||
const [isProcessing, setIsProcessing] = useState(false);
|
const [isProcessing, setIsProcessing] = useState(false);
|
||||||
const [ripples, setRipples] = useState<Array<{ id: number; x: number; y: number }>>([]);
|
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 = () => {
|
const triggerHaptic = () => {
|
||||||
if (haptic && navigator.vibrate) {
|
if (haptic && navigator.vibrate) {
|
||||||
@@ -102,7 +69,6 @@ export default function EnhancedButton({
|
|||||||
if (disabled || loading || isProcessing) return;
|
if (disabled || loading || isProcessing) return;
|
||||||
|
|
||||||
createRipple(e);
|
createRipple(e);
|
||||||
playSound('click');
|
|
||||||
triggerHaptic();
|
triggerHaptic();
|
||||||
|
|
||||||
if (onClick) {
|
if (onClick) {
|
||||||
@@ -113,10 +79,8 @@ export default function EnhancedButton({
|
|||||||
// 如果返回的是 Promise,等待它完成
|
// 如果返回的是 Promise,等待它完成
|
||||||
if (result instanceof Promise) {
|
if (result instanceof Promise) {
|
||||||
await result;
|
await result;
|
||||||
playSound('success');
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
playSound('error');
|
|
||||||
console.error('Button click error:', error);
|
console.error('Button click error:', error);
|
||||||
} finally {
|
} finally {
|
||||||
setIsProcessing(false);
|
setIsProcessing(false);
|
||||||
|
|||||||
@@ -192,7 +192,6 @@ export function ErrorNotification({ message, type = 'error', duration = 5000, on
|
|||||||
class ErrorManager {
|
class ErrorManager {
|
||||||
private static instance: ErrorManager;
|
private static instance: ErrorManager;
|
||||||
private listeners: Array<(notification: ErrorNotificationProps & { id: string }) => void> = [];
|
private listeners: Array<(notification: ErrorNotificationProps & { id: string }) => void> = [];
|
||||||
private soundEnabled: boolean = true;
|
|
||||||
|
|
||||||
static getInstance(): ErrorManager {
|
static getInstance(): ErrorManager {
|
||||||
if (!ErrorManager.instance) {
|
if (!ErrorManager.instance) {
|
||||||
@@ -201,51 +200,19 @@ class ErrorManager {
|
|||||||
return ErrorManager.instance;
|
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) {
|
showError(message: string, duration?: number) {
|
||||||
this.playSound('error');
|
|
||||||
this.showNotification(message, 'error', duration);
|
this.showNotification(message, 'error', duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
showWarning(message: string, duration?: number) {
|
showWarning(message: string, duration?: number) {
|
||||||
this.playSound('warning');
|
|
||||||
this.showNotification(message, 'warning', duration);
|
this.showNotification(message, 'warning', duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
showSuccess(message: string, duration?: number) {
|
showSuccess(message: string, duration?: number) {
|
||||||
this.playSound('success');
|
|
||||||
this.showNotification(message, 'success', duration);
|
this.showNotification(message, 'success', duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
showInfo(message: string, duration?: number) {
|
showInfo(message: string, duration?: number) {
|
||||||
this.playSound('info');
|
|
||||||
this.showNotification(message, 'info', duration);
|
this.showNotification(message, 'info', duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,10 +233,6 @@ class ErrorManager {
|
|||||||
this.listeners = this.listeners.filter(l => l !== listener);
|
this.listeners = this.listeners.filter(l => l !== listener);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
setSoundEnabled(enabled: boolean) {
|
|
||||||
this.soundEnabled = enabled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const errorManager = ErrorManager.getInstance();
|
export const errorManager = ErrorManager.getInstance();
|
||||||
@@ -277,7 +240,6 @@ export const errorManager = ErrorManager.getInstance();
|
|||||||
// 增强的错误提示容器组件
|
// 增强的错误提示容器组件
|
||||||
export function ErrorNotificationContainer() {
|
export function ErrorNotificationContainer() {
|
||||||
const [notifications, setNotifications] = useState<Array<ErrorNotificationProps & { id: string }>>([]);
|
const [notifications, setNotifications] = useState<Array<ErrorNotificationProps & { id: string }>>([]);
|
||||||
const [soundEnabled, setSoundEnabled] = useState(true);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const unsubscribe = errorManager.subscribe((notification) => {
|
const unsubscribe = errorManager.subscribe((notification) => {
|
||||||
@@ -287,10 +249,6 @@ export function ErrorNotificationContainer() {
|
|||||||
return unsubscribe;
|
return unsubscribe;
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
errorManager.setSoundEnabled(soundEnabled);
|
|
||||||
}, [soundEnabled]);
|
|
||||||
|
|
||||||
const removeNotification = (id: string) => {
|
const removeNotification = (id: string) => {
|
||||||
setNotifications(prev => prev.filter(n => n.id !== id));
|
setNotifications(prev => prev.filter(n => n.id !== id));
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,22 +1,19 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { motion, AnimatePresence, useScroll, useTransform } from 'framer-motion';
|
import { motion, AnimatePresence, useScroll } from 'framer-motion';
|
||||||
import { useState, useCallback, useEffect } from 'react';
|
import { useState, useCallback, useMemo, useEffect } from 'react';
|
||||||
import {
|
import {
|
||||||
HomeIcon,
|
HomeIcon,
|
||||||
ArrowLeftIcon,
|
ArrowLeftIcon,
|
||||||
ExclamationTriangleIcon,
|
ExclamationTriangleIcon,
|
||||||
XCircleIcon,
|
|
||||||
ClockIcon,
|
ClockIcon,
|
||||||
ServerIcon,
|
ServerIcon,
|
||||||
WifiIcon,
|
WifiIcon,
|
||||||
ClipboardDocumentIcon,
|
ClipboardDocumentIcon,
|
||||||
ArrowPathIcon,
|
ArrowPathIcon,
|
||||||
CubeIcon,
|
CubeIcon,
|
||||||
QuestionMarkCircleIcon,
|
QuestionMarkCircleIcon
|
||||||
SparklesIcon,
|
|
||||||
RocketLaunchIcon
|
|
||||||
} from '@heroicons/react/24/outline';
|
} from '@heroicons/react/24/outline';
|
||||||
import { messageManager } from './MessageNotification';
|
import { messageManager } from './MessageNotification';
|
||||||
|
|
||||||
@@ -172,9 +169,7 @@ export function ErrorPage({
|
|||||||
const [isRetrying, setIsRetrying] = useState(false);
|
const [isRetrying, setIsRetrying] = useState(false);
|
||||||
const [showDetails, setShowDetails] = useState(false);
|
const [showDetails, setShowDetails] = useState(false);
|
||||||
const [copySuccess, setCopySuccess] = useState(false);
|
const [copySuccess, setCopySuccess] = useState(false);
|
||||||
const [mousePosition, setMousePosition] = useState({ x: 0, y: 0 });
|
useScroll(); // keep hook for future use
|
||||||
const { scrollYProgress } = useScroll();
|
|
||||||
const opacity = useTransform(scrollYProgress, [0, 0.3], [1, 0.8]);
|
|
||||||
|
|
||||||
const config = errorConfigs[type] || {};
|
const config = errorConfigs[type] || {};
|
||||||
const displayTitle = title || config.title || '出错了';
|
const displayTitle = title || config.title || '出错了';
|
||||||
@@ -194,7 +189,8 @@ export function ErrorPage({
|
|||||||
return JSON.stringify(details, null, 2);
|
return JSON.stringify(details, null, 2);
|
||||||
}, [type, code, errorDetails]);
|
}, [type, code, errorDetails]);
|
||||||
|
|
||||||
const defaultActions = {
|
const finalActions = useMemo(() => {
|
||||||
|
const defaults = {
|
||||||
primary: {
|
primary: {
|
||||||
label: '返回主城',
|
label: '返回主城',
|
||||||
href: '/'
|
href: '/'
|
||||||
@@ -208,18 +204,8 @@ export function ErrorPage({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
return { ...defaults, ...actions };
|
||||||
const finalActions = { ...defaultActions, ...actions };
|
}, [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'
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const getIconColor = () => {
|
const getIconColor = () => {
|
||||||
const colors = {
|
const colors = {
|
||||||
@@ -251,13 +237,13 @@ export function ErrorPage({
|
|||||||
return 'from-orange-500 to-amber-500 hover:from-orange-600 hover:to-amber-600';
|
return 'from-orange-500 to-amber-500 hover:from-orange-600 hover:to-amber-600';
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRetry = async () => {
|
const handleRetry = useCallback(async () => {
|
||||||
if (onRetry) {
|
if (onRetry) {
|
||||||
setIsRetrying(true);
|
setIsRetrying(true);
|
||||||
try {
|
try {
|
||||||
await onRetry();
|
await onRetry();
|
||||||
messageManager.success('重试成功!', { duration: 3000 });
|
messageManager.success('重试成功!', { duration: 3000 });
|
||||||
} catch (error) {
|
} catch {
|
||||||
messageManager.error('重试失败,请稍后重试', { duration: 5000 });
|
messageManager.error('重试失败,请稍后重试', { duration: 5000 });
|
||||||
} finally {
|
} finally {
|
||||||
setIsRetrying(false);
|
setIsRetrying(false);
|
||||||
@@ -268,9 +254,9 @@ export function ErrorPage({
|
|||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}, [onRetry]);
|
||||||
|
|
||||||
const handleCopyError = async () => {
|
const handleCopyError = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
const details = generateErrorDetails();
|
const details = generateErrorDetails();
|
||||||
if (typeof navigator !== 'undefined' && navigator.clipboard) {
|
if (typeof navigator !== 'undefined' && navigator.clipboard) {
|
||||||
@@ -290,15 +276,10 @@ export function ErrorPage({
|
|||||||
messageManager.success('错误信息已复制到剪贴板', { duration: 2000 });
|
messageManager.success('错误信息已复制到剪贴板', { duration: 2000 });
|
||||||
setTimeout(() => setCopySuccess(false), 2000);
|
setTimeout(() => setCopySuccess(false), 2000);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
messageManager.error('复制失败,请手动复制', { duration: 3000 });
|
messageManager.error('复制失败,请手动复制', { duration: 3000 });
|
||||||
}
|
}
|
||||||
};
|
}, [generateErrorDetails]);
|
||||||
|
|
||||||
const handleReportError = () => {
|
|
||||||
messageManager.info('感谢您的反馈,我们会尽快处理', { duration: 3000 });
|
|
||||||
// 这里可以添加实际的错误报告逻辑
|
|
||||||
};
|
|
||||||
|
|
||||||
// 键盘快捷键支持
|
// 键盘快捷键支持
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -315,8 +296,6 @@ export function ErrorPage({
|
|||||||
}
|
}
|
||||||
}, [handleRetry]);
|
}, [handleRetry]);
|
||||||
|
|
||||||
const themeStyles = getThemeStyles();
|
|
||||||
|
|
||||||
return (
|
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}`}>
|
<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 - 简化背景动画 */}
|
{/* Animated Background - 简化背景动画 */}
|
||||||
|
|||||||
@@ -6,14 +6,12 @@ import { ReactNode } from 'react';
|
|||||||
interface LoadingSpinnerProps {
|
interface LoadingSpinnerProps {
|
||||||
size?: 'sm' | 'md' | 'lg' | 'xl';
|
size?: 'sm' | 'md' | 'lg' | 'xl';
|
||||||
color?: 'orange' | 'blue' | 'green' | 'red' | 'purple' | 'gray';
|
color?: 'orange' | 'blue' | 'green' | 'red' | 'purple' | 'gray';
|
||||||
speed?: 'slow' | 'normal' | 'fast';
|
|
||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LoadingSpinner({
|
export function LoadingSpinner({
|
||||||
size = 'md',
|
size = 'md',
|
||||||
color = 'orange',
|
color = 'orange',
|
||||||
speed = 'normal',
|
|
||||||
className = ''
|
className = ''
|
||||||
}: LoadingSpinnerProps) {
|
}: LoadingSpinnerProps) {
|
||||||
const sizes = {
|
const sizes = {
|
||||||
@@ -32,12 +30,6 @@ export function LoadingSpinner({
|
|||||||
gray: 'border-gray-500'
|
gray: 'border-gray-500'
|
||||||
};
|
};
|
||||||
|
|
||||||
const speeds = {
|
|
||||||
slow: 'duration-2000',
|
|
||||||
normal: 'duration-1000',
|
|
||||||
fast: 'duration-500'
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<motion.div
|
<motion.div
|
||||||
className={`${sizes[size]} ${colors[color]} border-2 border-t-transparent rounded-full animate-spin ${className}`}
|
className={`${sizes[size]} ${colors[color]} border-2 border-t-transparent rounded-full animate-spin ${className}`}
|
||||||
|
|||||||
@@ -7,8 +7,7 @@ import {
|
|||||||
ExclamationTriangleIcon,
|
ExclamationTriangleIcon,
|
||||||
CheckCircleIcon,
|
CheckCircleIcon,
|
||||||
InformationCircleIcon,
|
InformationCircleIcon,
|
||||||
XCircleIcon,
|
XCircleIcon
|
||||||
BellIcon
|
|
||||||
} from '@heroicons/react/24/outline';
|
} from '@heroicons/react/24/outline';
|
||||||
|
|
||||||
export type MessageType = 'success' | 'error' | 'warning' | 'info' | 'loading';
|
export type MessageType = 'success' | 'error' | 'warning' | 'info' | 'loading';
|
||||||
|
|||||||
@@ -5,14 +5,13 @@ import Link from 'next/link';
|
|||||||
import { useRouter, usePathname } from 'next/navigation';
|
import { useRouter, usePathname } from 'next/navigation';
|
||||||
import { Bars3Icon, XMarkIcon, UserCircleIcon } from '@heroicons/react/24/outline';
|
import { Bars3Icon, XMarkIcon, UserCircleIcon } from '@heroicons/react/24/outline';
|
||||||
import { motion, AnimatePresence, useScroll, useTransform, useSpring } from 'framer-motion';
|
import { motion, AnimatePresence, useScroll, useTransform, useSpring } from 'framer-motion';
|
||||||
|
import { Carrot } from 'lucide-react';
|
||||||
import { useAuth } from '@/contexts/AuthContext';
|
import { useAuth } from '@/contexts/AuthContext';
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
const [isHidden, setIsHidden] = useState(false);
|
const [isHidden, setIsHidden] = useState(false);
|
||||||
const [isScrolled, setIsScrolled] = useState(false);
|
const [isScrolled, setIsScrolled] = useState(false);
|
||||||
const [showScrollTop, setShowScrollTop] = useState(false);
|
|
||||||
const [navbarHeight, setNavbarHeight] = useState(0);
|
|
||||||
const [scrollProgress, setScrollProgress] = useState(0);
|
const [scrollProgress, setScrollProgress] = useState(0);
|
||||||
const navbarRef = useRef<HTMLElement>(null);
|
const navbarRef = useRef<HTMLElement>(null);
|
||||||
const { user, isAuthenticated, isLoading: isAuthLoading, logout } = useAuth();
|
const { user, isAuthenticated, isLoading: isAuthLoading, logout } = useAuth();
|
||||||
@@ -24,7 +23,6 @@ export default function Navbar() {
|
|||||||
const springConfig = { stiffness: 300, damping: 30 };
|
const springConfig = { stiffness: 300, damping: 30 };
|
||||||
const navbarY = useSpring(useTransform(scrollY, [0, 100], [0, -100]), springConfig);
|
const navbarY = useSpring(useTransform(scrollY, [0, 100], [0, -100]), springConfig);
|
||||||
const navbarOpacity = useSpring(useTransform(scrollY, [0, 50], [1, 0.95]), springConfig);
|
const navbarOpacity = useSpring(useTransform(scrollY, [0, 50], [1, 0.95]), springConfig);
|
||||||
const scrollProgressSpring = useSpring(scrollProgress, springConfig);
|
|
||||||
|
|
||||||
// 在auth页面隐藏navbar
|
// 在auth页面隐藏navbar
|
||||||
const isAuthPage = pathname === '/auth';
|
const isAuthPage = pathname === '/auth';
|
||||||
@@ -34,7 +32,6 @@ export default function Navbar() {
|
|||||||
const updateHeight = () => {
|
const updateHeight = () => {
|
||||||
if (navbarRef.current) {
|
if (navbarRef.current) {
|
||||||
const height = navbarRef.current.offsetHeight;
|
const height = navbarRef.current.offsetHeight;
|
||||||
setNavbarHeight(height);
|
|
||||||
document.documentElement.style.setProperty('--navbar-height', `${height}px`);
|
document.documentElement.style.setProperty('--navbar-height', `${height}px`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -69,9 +66,6 @@ export default function Navbar() {
|
|||||||
// 检测是否滚动到顶部
|
// 检测是否滚动到顶部
|
||||||
setIsScrolled(currentScrollY > 20);
|
setIsScrolled(currentScrollY > 20);
|
||||||
|
|
||||||
// 显示返回顶部按钮(滚动超过300px)
|
|
||||||
setShowScrollTop(currentScrollY > 300);
|
|
||||||
|
|
||||||
// 更敏感的隐藏逻辑:只要往下滚动就隐藏,不管滚动多少
|
// 更敏感的隐藏逻辑:只要往下滚动就隐藏,不管滚动多少
|
||||||
if (!isAuthPage && currentScrollY > lastScrollY && currentScrollY > 10) {
|
if (!isAuthPage && currentScrollY > lastScrollY && currentScrollY > 10) {
|
||||||
setIsHidden(true);
|
setIsHidden(true);
|
||||||
@@ -108,13 +102,6 @@ export default function Navbar() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const scrollToTop = () => {
|
|
||||||
window.scrollTo({
|
|
||||||
top: 0,
|
|
||||||
behavior: 'smooth',
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const navItems = [
|
const navItems = [
|
||||||
{ href: '/', label: '首页', icon: null },
|
{ href: '/', label: '首页', icon: null },
|
||||||
{ href: '/skins', label: '皮肤库', icon: null },
|
{ href: '/skins', label: '皮肤库', icon: null },
|
||||||
@@ -161,7 +148,7 @@ export default function Navbar() {
|
|||||||
whileHover={{ rotate: 5, scale: 1.05 }}
|
whileHover={{ rotate: 5, scale: 1.05 }}
|
||||||
transition={{ type: 'spring', stiffness: 300 }}
|
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
|
<motion.div
|
||||||
className="absolute inset-0 bg-gradient-to-br from-white/20 to-transparent"
|
className="absolute inset-0 bg-gradient-to-br from-white/20 to-transparent"
|
||||||
initial={{ x: '-100%', y: '-100%' }}
|
initial={{ x: '-100%', y: '-100%' }}
|
||||||
@@ -237,6 +224,7 @@ export default function Navbar() {
|
|||||||
className="relative"
|
className="relative"
|
||||||
whileHover={{ scale: 1.1, rotate: 5 }}
|
whileHover={{ scale: 1.1, rotate: 5 }}
|
||||||
>
|
>
|
||||||
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
<img
|
<img
|
||||||
src={user.avatar}
|
src={user.avatar}
|
||||||
alt={user.username}
|
alt={user.username}
|
||||||
@@ -405,6 +393,7 @@ export default function Navbar() {
|
|||||||
>
|
>
|
||||||
<div className="flex items-center space-x-3">
|
<div className="flex items-center space-x-3">
|
||||||
{user?.avatar ? (
|
{user?.avatar ? (
|
||||||
|
/* eslint-disable-next-line @next/next/no-img-element */
|
||||||
<img
|
<img
|
||||||
src={user.avatar}
|
src={user.avatar}
|
||||||
alt={user.username}
|
alt={user.username}
|
||||||
@@ -468,7 +457,7 @@ export default function Navbar() {
|
|||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
</motion.nav>
|
</motion.nav>
|
||||||
|
|
||||||
{/* 返回顶部按钮 */}
|
{/* 返回顶部按钮 - 已注释掉,如需使用请恢复 showScrollTop 状态 */}
|
||||||
{/* <AnimatePresence>
|
{/* <AnimatePresence>
|
||||||
{showScrollTop && (
|
{showScrollTop && (
|
||||||
<motion.button
|
<motion.button
|
||||||
@@ -477,7 +466,7 @@ export default function Navbar() {
|
|||||||
exit={{ opacity: 0, scale: 0.8, y: 20 }}
|
exit={{ opacity: 0, scale: 0.8, y: 20 }}
|
||||||
whileHover={{ scale: 1.1, y: -2 }}
|
whileHover={{ scale: 1.1, y: -2 }}
|
||||||
whileTap={{ scale: 0.9 }}
|
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"
|
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
|
<motion.div
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { motion, AnimatePresence } from 'framer-motion';
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { EyeIcon, ArrowDownTrayIcon, HeartIcon } from '@heroicons/react/24/outline';
|
import { EyeIcon, ArrowDownTrayIcon, HeartIcon } from '@heroicons/react/24/outline';
|
||||||
import { HeartIcon as HeartIconSolid } from '@heroicons/react/24/solid';
|
import { HeartIcon as HeartIconSolid } from '@heroicons/react/24/solid';
|
||||||
|
import { Shirt } from 'lucide-react';
|
||||||
import SkinViewer from './SkinViewer';
|
import SkinViewer from './SkinViewer';
|
||||||
import type { Texture } from '@/lib/api';
|
import type { Texture } from '@/lib/api';
|
||||||
|
|
||||||
@@ -197,7 +198,7 @@ export default function SkinCard({
|
|||||||
transition={{ type: 'spring' as const, stiffness: 300 }}
|
transition={{ type: 'spring' as const, stiffness: 300 }}
|
||||||
animate={imageLoaded ? {} : { scale: [0.8, 1, 0.8] }}
|
animate={imageLoaded ? {} : { scale: [0.8, 1, 0.8] }}
|
||||||
>
|
>
|
||||||
<span className="text-2xl">🧥</span>
|
<Shirt className="w-10 h-10 text-orange-500" />
|
||||||
</motion.div>
|
</motion.div>
|
||||||
<p className="text-sm text-gray-600 dark:text-gray-300 font-medium">披风</p>
|
<p className="text-sm text-gray-600 dark:text-gray-300 font-medium">披风</p>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
@@ -406,13 +407,13 @@ export default function SkinCard({
|
|||||||
</motion.span>
|
</motion.span>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-gray-400">
|
<div className="text-xs text-gray-400">
|
||||||
{texture.uploader_id && (
|
{texture.uploader_username && (
|
||||||
<motion.span
|
<motion.span
|
||||||
initial={{ opacity: 0 }}
|
initial={{ opacity: 0 }}
|
||||||
animate={{ opacity: 1 }}
|
animate={{ opacity: 1 }}
|
||||||
transition={{ delay: index * 0.1 + 0.6 }}
|
transition={{ delay: index * 0.1 + 0.6 }}
|
||||||
>
|
>
|
||||||
by User #{texture.uploader_id}
|
by {texture.uploader_username}
|
||||||
</motion.span>
|
</motion.span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -18,9 +18,7 @@ interface SkinDetailModalProps {
|
|||||||
favorite_count?: number;
|
favorite_count?: number;
|
||||||
download_count?: number;
|
download_count?: number;
|
||||||
created_at?: string;
|
created_at?: string;
|
||||||
uploader?: {
|
uploader_username?: string;
|
||||||
username: string;
|
|
||||||
};
|
|
||||||
} | null;
|
} | null;
|
||||||
isExternalPreview?: boolean;
|
isExternalPreview?: boolean;
|
||||||
}
|
}
|
||||||
@@ -32,16 +30,19 @@ export default function SkinDetailModal({ isOpen, onClose, texture, isExternalPr
|
|||||||
const [isMinimized, setIsMinimized] = useState(false);
|
const [isMinimized, setIsMinimized] = useState(false);
|
||||||
const [isPaused, setIsPaused] = useState(false); // 新增:动画暂停状态
|
const [isPaused, setIsPaused] = useState(false); // 新增:动画暂停状态
|
||||||
|
|
||||||
// 重置状态当对话框关闭时
|
// 重置状态当对话框关闭时 - 使用事件循环避免同步 setState
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
|
const timer = setTimeout(() => {
|
||||||
setCurrentAnimation('idle');
|
setCurrentAnimation('idle');
|
||||||
setAutoRotate(!isExternalPreview);
|
setAutoRotate(!isExternalPreview);
|
||||||
setRotation(true);
|
setRotation(true);
|
||||||
setIsMinimized(false);
|
setIsMinimized(false);
|
||||||
setIsPaused(false); // 重置暂停状态
|
setIsPaused(false);
|
||||||
|
}, 0);
|
||||||
|
return () => clearTimeout(timer);
|
||||||
}
|
}
|
||||||
}, [isOpen]);
|
}, [isOpen, isExternalPreview]);
|
||||||
|
|
||||||
// 键盘事件处理
|
// 键盘事件处理
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -286,10 +287,10 @@ export default function SkinDetailModal({ isOpen, onClose, texture, isExternalPr
|
|||||||
{ key: 'walking', label: '步行', icon: null },
|
{ key: 'walking', label: '步行', icon: null },
|
||||||
{ key: 'running', label: '跑步', icon: null },
|
{ key: 'running', label: '跑步', icon: null },
|
||||||
{ key: 'swimming', label: '游泳', icon: null }
|
{ key: 'swimming', label: '游泳', icon: null }
|
||||||
].map((anim, i) => (
|
].map((anim) => (
|
||||||
<button
|
<button
|
||||||
key={anim.key}
|
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 ${
|
className={`p-4 rounded-xl text-sm font-semibold transition-all duration-200 ${
|
||||||
currentAnimation === anim.key
|
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'
|
? '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">
|
<div className="space-y-2 text-sm">
|
||||||
{texture.uploader && (
|
{texture.uploader_username && (
|
||||||
<motion.div
|
<motion.div
|
||||||
className="flex justify-between items-center"
|
className="flex justify-between items-center"
|
||||||
initial={{ opacity: 0, x: -10 }}
|
initial={{ opacity: 0, x: -10 }}
|
||||||
@@ -335,7 +336,7 @@ export default function SkinDetailModal({ isOpen, onClose, texture, isExternalPr
|
|||||||
transition={{ delay: 1.0 }}
|
transition={{ delay: 1.0 }}
|
||||||
>
|
>
|
||||||
<span className="text-gray-600 dark:text-gray-400">上传者:</span>
|
<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>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useEffect, useRef, useState } from 'react';
|
import { useEffect, useRef, useState } from 'react';
|
||||||
|
import { AlertTriangle } from 'lucide-react';
|
||||||
import { SkinViewer as SkinViewer3D, WalkingAnimation, RunningAnimation, FlyingAnimation, IdleAnimation } from 'skinview3d';
|
import { SkinViewer as SkinViewer3D, WalkingAnimation, RunningAnimation, FlyingAnimation, IdleAnimation } from 'skinview3d';
|
||||||
|
|
||||||
interface SkinViewerProps {
|
interface SkinViewerProps {
|
||||||
@@ -44,50 +45,64 @@ export default function SkinViewer({
|
|||||||
|
|
||||||
// 预加载皮肤图片以检查是否可访问
|
// 预加载皮肤图片以检查是否可访问
|
||||||
useEffect(() => {
|
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);
|
setIsLoading(true);
|
||||||
setHasError(false);
|
setHasError(false);
|
||||||
setImageLoaded(false);
|
setImageLoaded(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
let isCancelled = false;
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
img.crossOrigin = 'anonymous'; // 尝试跨域访问
|
img.crossOrigin = 'anonymous';
|
||||||
|
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
|
if (isCancelled) return;
|
||||||
console.log('皮肤图片加载成功:', skinUrl);
|
console.log('皮肤图片加载成功:', skinUrl);
|
||||||
setImageLoaded(true);
|
setImageLoaded(true);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
if (onImageLoaded) {
|
onImageLoaded?.();
|
||||||
onImageLoaded();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
img.onerror = (error) => {
|
img.onerror = () => {
|
||||||
console.error('皮肤图片加载失败:', skinUrl, error);
|
if (isCancelled) return;
|
||||||
|
console.error('皮肤图片加载失败:', skinUrl);
|
||||||
setHasError(true);
|
setHasError(true);
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 开始加载图片
|
|
||||||
img.src = skinUrl;
|
img.src = skinUrl;
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
// 清理
|
cancelAnimationFrame(initFrame);
|
||||||
|
isCancelled = true;
|
||||||
img.onload = null;
|
img.onload = null;
|
||||||
img.onerror = null;
|
img.onerror = null;
|
||||||
};
|
};
|
||||||
}, [skinUrl]);
|
}, [skinUrl, onImageLoaded]);
|
||||||
|
|
||||||
// 初始化3D查看器
|
// 初始化3D查看器
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!canvasRef.current || !imageLoaded || hasError) return;
|
if (!canvasRef.current || !imageLoaded || hasError) return;
|
||||||
|
|
||||||
|
const canvas = canvasRef.current;
|
||||||
|
let viewer: SkinViewer3D | null = null;
|
||||||
|
|
||||||
|
// 使用 requestAnimationFrame 避免在 effect 体中同步 setState
|
||||||
|
const initFrame = requestAnimationFrame(() => {
|
||||||
try {
|
try {
|
||||||
console.log('初始化3D皮肤查看器:', { skinUrl, isSlim, width, height });
|
console.log('初始化3D皮肤查看器:', { skinUrl, isSlim, width, height });
|
||||||
|
|
||||||
// 使用传入的宽高参数初始化
|
viewer = new SkinViewer3D({
|
||||||
const canvas = canvasRef.current;
|
|
||||||
const viewer = new SkinViewer3D({
|
|
||||||
canvas: canvas,
|
canvas: canvas,
|
||||||
width: width,
|
width: width,
|
||||||
height: height,
|
height: height,
|
||||||
@@ -117,14 +132,15 @@ export default function SkinViewer({
|
|||||||
viewer.controls.enablePan = false; // 禁用平移
|
viewer.controls.enablePan = false; // 禁用平移
|
||||||
|
|
||||||
console.log('3D皮肤查看器初始化成功');
|
console.log('3D皮肤查看器初始化成功');
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('3D皮肤查看器初始化失败:', error);
|
console.error('3D皮肤查看器初始化失败:', error);
|
||||||
setHasError(true);
|
setHasError(true);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// 清理函数
|
// 清理函数
|
||||||
return () => {
|
return () => {
|
||||||
|
cancelAnimationFrame(initFrame);
|
||||||
if (viewerRef.current) {
|
if (viewerRef.current) {
|
||||||
try {
|
try {
|
||||||
viewerRef.current.dispose();
|
viewerRef.current.dispose();
|
||||||
@@ -248,7 +264,9 @@ export default function SkinViewer({
|
|||||||
style={{ width: width, height: height }}
|
style={{ width: width, height: height }}
|
||||||
>
|
>
|
||||||
<div className="text-center p-4">
|
<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 className="text-sm text-red-600 dark:text-red-400 font-medium mb-1">
|
||||||
皮肤加载失败
|
皮肤加载失败
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export const SliderCaptcha: React.FC<SliderCaptchaProps> = ({ onVerify, onClose
|
|||||||
const response = await axios.get(`${API_BASE_URL}/captcha/generate`, {
|
const response = await axios.get(`${API_BASE_URL}/captcha/generate`, {
|
||||||
withCredentials: true // 关键:允许跨域携带凭证
|
withCredentials: true // 关键:允许跨域携带凭证
|
||||||
});
|
});
|
||||||
const { code, msg: resMsg, data } = response.data;
|
const { code, message: resMsg, data } = response.data;
|
||||||
const { masterImage, tileImage, captchaId, y } = data;
|
const { masterImage, tileImage, captchaId, y } = data;
|
||||||
|
|
||||||
// 后端返回成功状态(code=200)
|
// 后端返回成功状态(code=200)
|
||||||
@@ -170,7 +170,7 @@ export const SliderCaptcha: React.FC<SliderCaptchaProps> = ({ onVerify, onClose
|
|||||||
captchaId: processId // 验证码进程ID
|
captchaId: processId // 验证码进程ID
|
||||||
},{ withCredentials: true });
|
},{ withCredentials: true });
|
||||||
|
|
||||||
const { code, msg: resMsg, data } = response.data;
|
const { code, message: resMsg } = response.data;
|
||||||
// 保存后端返回的提示信息
|
// 保存后端返回的提示信息
|
||||||
setMsg(resMsg);
|
setMsg(resMsg);
|
||||||
|
|
||||||
@@ -400,10 +400,11 @@ export const SliderCaptcha: React.FC<SliderCaptchaProps> = ({ onVerify, onClose
|
|||||||
{/* 背景图片容器:尺寸300x200px,与后端图片尺寸匹配 */}
|
{/* 背景图片容器:尺寸300x200px,与后端图片尺寸匹配 */}
|
||||||
<div className="relative bg-gray-200 rounded-lg w-[300px] h-[200px] mb-4 overflow-hidden mx-auto">
|
<div className="relative bg-gray-200 rounded-lg w-[300px] h-[200px] mb-4 overflow-hidden mx-auto">
|
||||||
{backgroundImage && (
|
{backgroundImage && (
|
||||||
|
/* eslint-disable-next-line @next/next/no-img-element */
|
||||||
<img
|
<img
|
||||||
src={backgroundImage}
|
src={backgroundImage}
|
||||||
alt="验证背景"
|
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
|
<div
|
||||||
className={`absolute ${isDragging ? '' : 'transition-all duration-300'}`}
|
className={`absolute ${isDragging ? '' : 'transition-all duration-300'}`}
|
||||||
style={{
|
style={{
|
||||||
left: `${sliderPosition}px`, // 滑块x位置(拼图左上角x坐标)
|
left: `${sliderPosition}px`,
|
||||||
top: `${puzzleY}px`, // 拼图y位置(从后端获取,拼图左上角y坐标)
|
top: `${puzzleY}px`,
|
||||||
zIndex: 10,
|
zIndex: 10,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||||||
<img
|
<img
|
||||||
src={puzzleImage}
|
src={puzzleImage}
|
||||||
alt="拼图块"
|
alt="拼图块"
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { motion } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import { PhotoIcon, ArrowDownTrayIcon, EyeIcon, HeartIcon } from '@heroicons/react/24/outline';
|
import { HeartIcon } from '@heroicons/react/24/outline';
|
||||||
import { HeartIcon as HeartIconSolid } from '@heroicons/react/24/solid';
|
|
||||||
import SkinCard from '@/components/SkinCard';
|
import SkinCard from '@/components/SkinCard';
|
||||||
import SkinDetailModal from '@/components/SkinDetailModal';
|
import SkinDetailModal from '@/components/SkinDetailModal';
|
||||||
import type { Texture } from '@/lib/api';
|
import type { Texture } from '@/lib/api';
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion } from 'framer-motion';
|
||||||
import {
|
import {
|
||||||
PhotoIcon,
|
PhotoIcon,
|
||||||
ArrowDownTrayIcon,
|
CloudArrowUpIcon,
|
||||||
EyeIcon,
|
TrashIcon
|
||||||
TrashIcon,
|
|
||||||
CloudArrowUpIcon
|
|
||||||
} from '@heroicons/react/24/outline';
|
} from '@heroicons/react/24/outline';
|
||||||
import SkinCard from '@/components/SkinCard';
|
import SkinCard from '@/components/SkinCard';
|
||||||
import SkinDetailModal from '@/components/SkinDetailModal';
|
import SkinDetailModal from '@/components/SkinDetailModal';
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
checkAuthStatus();
|
checkAuthStatus();
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const setAuthToken = (token: string) => {
|
const setAuthToken = (token: string) => {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || '/api/v1';
|
|||||||
export interface Texture {
|
export interface Texture {
|
||||||
id: number;
|
id: number;
|
||||||
uploader_id: number;
|
uploader_id: number;
|
||||||
|
uploader_username?: string;
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
type: 'SKIN' | 'CAPE';
|
type: 'SKIN' | 'CAPE';
|
||||||
@@ -24,7 +25,6 @@ export interface Profile {
|
|||||||
name: string;
|
name: string;
|
||||||
skin_id?: number;
|
skin_id?: number;
|
||||||
cape_id?: number;
|
cape_id?: number;
|
||||||
is_active?: boolean;
|
|
||||||
last_used_at?: string;
|
last_used_at?: string;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user