26aa13b5a4
ci/woodpecker/push/woodpecker Pipeline is running
优化内容: - Lint、Type Check、Security Scan并行执行 - Unit Tests使用depends_on等待所有检查完成 - 添加npm缓存配置 - 修复shared-mocks.tsx的ESLint错误 预期效果: - 串行时间: 30s + 40s + 20s = 90s - 并行时间: max(30s, 40s, 20s) = 40s - 节省时间: 50s (55.6%改善)
197 lines
8.3 KiB
TypeScript
197 lines
8.3 KiB
TypeScript
'use client';
|
||
|
||
import { motion } from 'framer-motion';
|
||
import { useInView } from 'framer-motion';
|
||
import { useRef, useMemo } from 'react';
|
||
import Link from 'next/link';
|
||
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card';
|
||
import { Button } from '@/components/ui/button';
|
||
import { Badge } from '@/components/ui/badge';
|
||
import { ArrowRight, Check, TrendingUp } from 'lucide-react';
|
||
import { useProducts } from '@/hooks/use-products';
|
||
import { trackButtonClick } from '@/lib/analytics';
|
||
|
||
interface ProductsConfig {
|
||
enabled?: boolean;
|
||
showPricing?: boolean;
|
||
featuredProducts?: string[];
|
||
}
|
||
|
||
interface ProductsSectionProps {
|
||
config?: ProductsConfig;
|
||
}
|
||
|
||
export function ProductsSection({ config }: ProductsSectionProps) {
|
||
const ref = useRef(null);
|
||
const isInView = useInView(ref, { once: true, margin: '-100px' });
|
||
const { products, loading, error } = useProducts();
|
||
|
||
const filteredProducts = useMemo(() => {
|
||
if (!products || products.length === 0) {
|
||
return [];
|
||
}
|
||
if (!config?.featuredProducts || config.featuredProducts.length === 0) {
|
||
return products;
|
||
}
|
||
return products.filter(product => config.featuredProducts?.includes(product.id));
|
||
}, [products, config]);
|
||
|
||
if (loading) {
|
||
return (
|
||
<section id="products" role="region" aria-labelledby="products-heading" className="py-24 bg-[#F5F7FA] relative overflow-hidden">
|
||
<div className="container-wide relative z-10">
|
||
<div className="text-center">
|
||
<p className="text-lg text-[#5C5C5C]">加载中...</p>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
);
|
||
}
|
||
|
||
if (error) {
|
||
return (
|
||
<section id="products" role="region" aria-labelledby="products-heading" className="py-24 bg-[#F5F7FA] relative overflow-hidden">
|
||
<div className="container-wide relative z-10">
|
||
<div className="text-center">
|
||
<p className="text-lg text-red-600">加载产品信息失败,请稍后重试</p>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
);
|
||
}
|
||
|
||
return (
|
||
<section id="products" role="region" aria-labelledby="products-heading" className="py-24 bg-[#F5F7FA] relative overflow-hidden" ref={ref}>
|
||
<div className="absolute top-1/2 left-0 w-100 h-100 bg-[rgba(79,70,229,0.03)] rounded-full blur-3xl" />
|
||
<div className="absolute top-1/3 right-0 w-75 h-75 bg-[rgba(196,30,58,0.02)] rounded-full blur-3xl" />
|
||
<div className="container-wide relative z-10">
|
||
<motion.div
|
||
initial={{ opacity: 0, y: 20 }}
|
||
animate={isInView ? { opacity: 1, y: 0 } : {}}
|
||
transition={{ duration: 0.6 }}
|
||
className="text-center max-w-3xl mx-auto mb-16"
|
||
>
|
||
<h2 id="products-heading" className="text-4xl md:text-5xl font-bold text-[#1C1C1C] mb-6">
|
||
我们的<span className="text-[#C41E3A]">产品</span>
|
||
</h2>
|
||
<p className="text-lg text-[#5C5C5C]">
|
||
自主研发的企业级产品,助力企业高效运营,实现数字化转型
|
||
</p>
|
||
</motion.div>
|
||
|
||
{filteredProducts.length > 0 ? (
|
||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
|
||
{filteredProducts.map((product, idx) => (
|
||
<motion.div
|
||
key={product.id}
|
||
initial={{ opacity: 0, y: 20 }}
|
||
animate={isInView ? { opacity: 1, y: 0 } : {}}
|
||
transition={{ duration: 0.5, delay: 0.1 + idx * 0.1 }}
|
||
>
|
||
<Link href={`/products/${product.id}`} onClick={() => trackButtonClick(product.title, 'products_section')}>
|
||
<Card className="h-full flex flex-col group cursor-pointer border-[#E5E5E5] hover:border-[#1C1C1C] transition-colors">
|
||
<CardHeader>
|
||
<Badge variant="secondary" className="w-fit mb-3">
|
||
{product.category}
|
||
</Badge>
|
||
<CardTitle>{product.title}</CardTitle>
|
||
</CardHeader>
|
||
<CardContent className="flex-1 flex flex-col">
|
||
<CardDescription className="text-base leading-relaxed mb-4 flex-1">
|
||
{product.description}
|
||
</CardDescription>
|
||
|
||
<div className="mb-4">
|
||
<p className="text-sm font-medium text-[#1C1C1C] mb-2">核心功能</p>
|
||
<div className="flex flex-wrap gap-1.5">
|
||
{product.features.slice(0, 4).map((feature, idx) => (
|
||
<span
|
||
key={idx}
|
||
className="inline-flex items-center text-xs px-2 py-1 bg-[#FAFAFA] text-[#3D3D3D] rounded border border-[#E5E5E5]"
|
||
>
|
||
<Check className="w-3 h-3 mr-1 text-[#C41E3A]" />
|
||
{feature}
|
||
</span>
|
||
))}
|
||
</div>
|
||
</div>
|
||
|
||
<div className="mb-4">
|
||
<p className="text-sm font-medium text-[#1C1C1C] mb-2 flex items-center">
|
||
<TrendingUp className="w-4 h-4 mr-1 text-[#C41E3A]" />
|
||
核心价值
|
||
</p>
|
||
<ul className="space-y-1">
|
||
{product.benefits.map((benefit, idx) => (
|
||
<li key={idx} className="text-xs text-[#5C5C5C] flex items-start">
|
||
<span className="text-[#C41E3A] mr-1.5">•</span>
|
||
{benefit}
|
||
</li>
|
||
))}
|
||
</ul>
|
||
</div>
|
||
|
||
{config?.showPricing && product.pricing && (
|
||
<div className="mb-4 p-3 bg-[#F5F7FA] rounded-lg">
|
||
<p className="text-sm font-medium text-[#1C1C1C] mb-2">价格方案</p>
|
||
<div className="space-y-1">
|
||
{Object.entries(product.pricing).map(([key, value]) => (
|
||
<p key={key} className="text-xs text-[#5C5C5C]">
|
||
{value}
|
||
</p>
|
||
))}
|
||
</div>
|
||
</div>
|
||
)}
|
||
|
||
<Button variant="outline" className="w-full mt-auto group-hover:bg-[#A01830] group-hover:text-white group-hover:border-[#A01830] transition-colors">
|
||
了解详情
|
||
<ArrowRight className="ml-2 w-4 h-4" />
|
||
</Button>
|
||
</CardContent>
|
||
</Card>
|
||
</Link>
|
||
</motion.div>
|
||
))}
|
||
</div>
|
||
) : (
|
||
<div className="text-center py-12">
|
||
<p className="text-lg text-[#5C5C5C]">暂无产品信息</p>
|
||
</div>
|
||
)}
|
||
|
||
<motion.div
|
||
initial={{ opacity: 0, y: 20 }}
|
||
animate={isInView ? { opacity: 1, y: 0 } : {}}
|
||
transition={{ duration: 0.6, delay: 0.5 }}
|
||
className="mt-20 text-center"
|
||
>
|
||
<div className="bg-white rounded-2xl p-12 border border-[#E2E8F0] relative overflow-hidden">
|
||
<div className="absolute inset-0 pointer-events-none">
|
||
<div className="absolute top-0 right-0 w-64 h-64 bg-[rgba(79,70,229,0.03)] rounded-full blur-3xl" />
|
||
<div className="absolute bottom-0 left-0 w-48 h-48 bg-[rgba(196,30,58,0.02)] rounded-full blur-3xl" />
|
||
</div>
|
||
<div className="relative z-10">
|
||
<h3 className="text-2xl sm:text-3xl font-bold text-[#1A1A2E] mb-4">
|
||
需要定制化解决方案?
|
||
</h3>
|
||
<p className="text-[#718096] mb-8 max-w-2xl mx-auto">
|
||
我们的专业团队可以根据您的业务需求,提供量身定制的产品开发和系统集成服务
|
||
</p>
|
||
<Button
|
||
size="lg"
|
||
asChild
|
||
>
|
||
<Link href="/contact">
|
||
联系我们
|
||
<ArrowRight className="ml-2 w-4 h-4" />
|
||
</Link>
|
||
</Button>
|
||
</div>
|
||
</div>
|
||
</motion.div>
|
||
</div>
|
||
</section>
|
||
);
|
||
}
|