pref: 代码打包优化

This commit is contained in:
zdl
2025-10-13 19:53:13 +08:00
parent dcef2fab1a
commit cd50d718fe
20 changed files with 14957 additions and 173 deletions

View File

@@ -249,6 +249,7 @@ export default function SignInIllustration() {
if (response.ok && data.success) {
// 更新认证状态
await checkSession();
toast({
title: "登录成功",
description: "欢迎回来!",
@@ -281,8 +282,6 @@ export default function SignInIllustration() {
const authLoginType = 'phone';
if(useVerificationCode) { // 验证码登陆
credential = formData.phone;
authLoginType = 'phone';
if (!credential || !formData.verificationCode) {
toast({
title: "请填写完整信息",
@@ -294,10 +293,11 @@ export default function SignInIllustration() {
}
const result = await loginWithVerificationCode(credential, formData.verificationCode, authLoginType);
if (result.success) {
navigate("/home");
}
}else { // 密码登陆
} else { // 密码登陆
if (!credential || !formData.password) {
toast({
title: "请填写完整信息",
@@ -309,12 +309,37 @@ export default function SignInIllustration() {
}
const result = await login(credential, formData.password, authLoginType);
if (result.success) {
// ✅ 显示成功提示
toast({
title: "登录成功",
description: "欢迎回来!",
status: "success",
duration: 3000,
isClosable: true,
});
navigate("/home");
} else {
// ❌ 显示错误提示
toast({
title: "登录失败",
description: result.error || "请检查您的登录信息",
status: "error",
duration: 3000,
isClosable: true,
});
}
}
} catch (error) {
console.error('Login error:', error);
toast({
title: "登录失败",
description: error.message || "发生未预期的错误,请重试",
status: "error",
duration: 3000,
isClosable: true,
});
} finally {
setIsLoading(false);
}

View File

@@ -21,17 +21,15 @@ import heroBg from '../../assets/img/BackgroundCard1.png';
import '../../styles/home-animations.css';
export default function HomePage() {
const { user, isAuthenticated, isLoading } = useAuth();
const { user, isAuthenticated } = useAuth(); // ⚡ 移除 isLoading不再依赖它
const navigate = useNavigate();
// 移除统计数据动画
const [imageLoaded, setImageLoaded] = React.useState(false);
// 保留原有的调试信息
useEffect(() => {
console.log('🏠 HomePage AuthContext 状态:', {
user,
isAuthenticated,
isLoading,
hasUser: !!user,
userInfo: user ? {
id: user.id,
@@ -39,7 +37,7 @@ export default function HomePage() {
nickname: user.nickname
} : null
});
}, [user, isAuthenticated, isLoading]);
}, [user, isAuthenticated]);
// 核心功能配置 - 5个主要功能
const coreFeatures = [
@@ -136,17 +134,18 @@ export default function HomePage() {
bg="linear-gradient(135deg, #0E0C15 0%, #15131D 50%, #252134 100%)"
overflow="hidden"
>
{/* 背景图片和装饰 */}
{/* 背景图片和装饰 - 优化:延迟加载 */}
<Box
position="absolute"
top="0"
right="0"
w="50%"
h="100%"
bgImage={`url(${heroBg})`}
bgImage={imageLoaded ? `url(${heroBg})` : 'none'}
bgSize="cover"
bgPosition="center"
opacity={0.3}
opacity={imageLoaded ? 0.3 : 0}
transition="opacity 0.5s ease-in"
_after={{
content: '""',
position: 'absolute',
@@ -157,6 +156,15 @@ export default function HomePage() {
background: 'linear-gradient(90deg, rgba(14, 12, 21, 0.9) 0%, rgba(14, 12, 21, 0.3) 100%)'
}}
/>
{/* 预加载背景图片 */}
<Box display="none">
<img
src={heroBg}
alt=""
onLoad={() => setImageLoaded(true)}
onError={() => setImageLoaded(true)}
/>
</Box>
{/* 装饰性几何图形 */}
<Box
@@ -266,7 +274,7 @@ export default function HomePage() {
{/* 其他5个功能 */}
<SimpleGrid columns={{ base: 1, md: 2, lg: 3 }} spacing={6} w="100%">
{coreFeatures.slice(1).map((feature, index) => (
{coreFeatures.slice(1).map((feature) => (
<Card
key={feature.id}
bg="whiteAlpha.100"