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

@@ -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"