// src/views/Home/HomePage.js - 专业投资分析平台 import React, { useEffect, useCallback } from 'react'; import { Box, Container, Heading, Text, Card, CardBody, Badge, Button, Flex, VStack, HStack, SimpleGrid, useBreakpointValue } from '@chakra-ui/react'; import { useAuth } from '../../contexts/AuthContext'; import { useNavigate } from 'react-router-dom'; import heroBg from '../../assets/img/BackgroundCard1.png'; import '../../styles/home-animations.css'; import { logger } from '../../utils/logger'; import MidjourneyHeroSection from '../Community/components/MidjourneyHeroSection'; import { usePostHogTrack } from '../../hooks/usePostHogRedux'; import { ACQUISITION_EVENTS } from '../../lib/constants'; export default function HomePage() { const { user, isAuthenticated } = useAuth(); // ⚡ 移除 isLoading,不再依赖它 const navigate = useNavigate(); const { track } = usePostHogTrack(); // PostHog 追踪 const [imageLoaded, setImageLoaded] = React.useState(false); // 响应式配置 const heroHeight = useBreakpointValue({ base: '60vh', md: '80vh', lg: '100vh' }); const headingSize = useBreakpointValue({ base: 'xl', md: '3xl', lg: '4xl' }); const headingLetterSpacing = useBreakpointValue({ base: '-1px', md: '-1.5px', lg: '-2px' }); const heroTextSize = useBreakpointValue({ base: 'md', md: 'lg', lg: 'xl' }); const containerPx = useBreakpointValue({ base: 10, md: 10, lg: 10 }); const showDecorations = useBreakpointValue({ base: false, md: true }); // 保留原有的调试信息 useEffect(() => { logger.debug('HomePage', 'AuthContext状态', { userId: user?.id, username: user?.username, nickname: user?.nickname, isAuthenticated, hasUser: !!user }); }, [user?.id, isAuthenticated]); // 只依赖 user.id,避免无限循环 // 🎯 PostHog 追踪:页面浏览 useEffect(() => { track(ACQUISITION_EVENTS.LANDING_PAGE_VIEWED, { timestamp: new Date().toISOString(), is_authenticated: isAuthenticated, user_id: user?.id || null, }); }, [track, isAuthenticated, user?.id]); // 核心功能配置 - 5个主要功能 const coreFeatures = [ { id: 'news-catalyst', title: '新闻中心', description: '实时新闻事件分析,捕捉市场催化因子', icon: '📊', color: 'yellow', url: '/community', badge: '核心', featured: true }, { id: 'concepts', title: '概念中心', description: '热门概念与主题投资分析追踪', icon: '🎯', color: 'purple', url: '/concepts', badge: '热门' }, { id: 'stocks', title: '个股信息汇总', description: '全面的个股基本面信息整合', icon: '📈', color: 'blue', url: '/stocks', badge: '全面' }, { id: 'limit-analyse', title: '涨停板块分析', description: '涨停板数据深度分析与规律挖掘', icon: '🚀', color: 'green', url: '/limit-analyse', badge: '精准' }, { id: 'company', title: '个股罗盘', description: '个股全方位分析与投资决策支持', icon: '🧭', color: 'orange', url: '/company?scode=688256', badge: '专业' }, { id: 'trading-simulation', title: '模拟盘交易', description: '100万起始资金,体验真实交易环境', icon: '💰', color: 'teal', url: '/trading-simulation', badge: '实战' } ]; // @TODO 如何区分内部链接和外部链接? const handleProductClick = useCallback((feature) => { // 🎯 PostHog 追踪:功能卡片点击 track(ACQUISITION_EVENTS.FEATURE_CARD_CLICKED, { feature_id: feature.id, feature_title: feature.title, feature_url: feature.url, is_featured: feature.featured || false, link_type: feature.url.startsWith('http') ? 'external' : 'internal', }); // 原有导航逻辑 if (feature.url.startsWith('http')) { // 外部链接,直接打开 window.open(feature.url, '_blank'); } else { // 内部路由 navigate(feature.url); } }, [track, navigate]); return ( {/* 开发调试信息 */} {/* {process.env.NODE_ENV === 'development' && ( 认证: {isAuthenticated ? '✅' : '❌'} | 用户: {user?.nickname || '无'} )} */} {/* Hero Section - 深色科技风格 */} {/* 背景图片和装饰 - 优化:延迟加载 */} {/* 预加载背景图片 */} setImageLoaded(true)} onError={() => setImageLoaded(true)} /> {/* 装饰性几何图形 - 移动端隐藏 */} {showDecorations && ( <> )} {/* 主标题区域 */} 智能投资分析平台 专业投资研究工具,助您把握市场机遇 {/* 核心功能面板 */} {/* 新闻中心 - 突出显示 */} {/* 响应式布局:移动端纵向,桌面端横向 */} {coreFeatures[0].icon} {coreFeatures[0].title} {coreFeatures[0].badge} {coreFeatures[0].description} {/* 其他5个功能 */} {coreFeatures.slice(1).map((feature) => ( handleProductClick(feature)} minH={{ base: 'auto', md: '180px' }} > {feature.icon} {feature.badge} {feature.title} {feature.description} ))} {/* Midjourney风格英雄区域 */} ); }