import React, { useEffect, useState } from 'react'; import { Card, Row, Col, Tag, Button, Spin, Typography } from 'antd'; import { RocketOutlined, RightOutlined } from '@ant-design/icons'; import { useNavigate } from 'react-router-dom'; import { motion } from 'framer-motion'; import { getConfigs } from '../api'; import ActivityList from '../components/activity/ActivityList'; import './Home.css'; const { Title, Paragraph } = Typography; const Home = () => { const [products, setProducts] = useState([]); const [loading, setLoading] = useState(true); const [typedText, setTypedText] = useState(''); const [isTypingComplete, setIsTypingComplete] = useState(false); const fullText = "未来已来 AI 核心驱动"; const navigate = useNavigate(); useEffect(() => { fetchProducts(); let i = 0; const typingInterval = setInterval(() => { i++; setTypedText(fullText.slice(0, i)); if (i >= fullText.length) { clearInterval(typingInterval); setIsTypingComplete(true); } }, 150); return () => clearInterval(typingInterval); }, []); const fetchProducts = async () => { try { const response = await getConfigs(); setProducts(response.data); } catch (error) { console.error('Failed to fetch products:', error); } finally { setLoading(false); } }; const cardVariants = { hidden: { opacity: 0, y: 50 }, visible: (i) => ({ opacity: 1, y: 0, transition: { delay: i * 0.1, duration: 0.5, type: "spring", stiffness: 100 } }), hover: { scale: 1.05, rotateX: 5, rotateY: 5, transition: { duration: 0.3 } } }; if (loading) { return (
加载硬件配置中...
); } return (
<span className="neon-text-green">{typedText}</span> {!isTypingComplete && <span className="cursor-blink">|</span>} 量迹 AI 硬件为您提供最强大的边缘计算能力,搭载最新一代神经处理单元,赋能您的每一个创意。
{products.map((product, index) => ( {product.static_image_url ? ( {product.name} ) : ( )}
} onClick={() => navigate(`/product/${product.id}`)} >
{product.name}
{product.description}
{product.chip_type} {product.has_camera && Camera} {product.has_microphone && Mic}
¥{product.price}
))}
); }; export default Home;