refactor: 完成静态网站转换,移除所有 CMS 和动态功能

- 删除数据库相关代码 (src/db/)
- 删除 API 路由 (src/app/api/)
- 删除认证相关代码 (src/lib/auth/, src/providers/)
- 删除监控和安全中间件 (src/lib/security/, src/lib/monitoring/)
- 删除 hooks (use-news, use-products, use-services)
- 更新组件为静态数据源
- 添加 nginx 静态配置和部署脚本
- 添加 static-link 组件
This commit is contained in:
张翔
2026-04-21 07:53:56 +08:00
parent cd1d6aa28a
commit 6403489954
197 changed files with 654 additions and 24762 deletions
+11 -56
View File
@@ -2,62 +2,17 @@
import { motion } from 'framer-motion';
import { useInView } from 'framer-motion';
import { useRef, useMemo } from 'react';
import Link from 'next/link';
import { useRef } from 'react';
import { StaticLink } from '@/components/ui/static-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 { PRODUCTS } from '@/lib/constants';
interface ProductsConfig {
enabled?: boolean;
showPricing?: boolean;
featuredProducts?: string[];
}
interface ProductsSectionProps {
config?: ProductsConfig;
}
export function ProductsSection({ config }: ProductsSectionProps) {
export function ProductsSection() {
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}>
@@ -78,16 +33,16 @@ export function ProductsSection({ config }: ProductsSectionProps) {
</p>
</motion.div>
{filteredProducts.length > 0 ? (
{PRODUCTS.length > 0 ? (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
{filteredProducts.map((product, idx) => (
{PRODUCTS.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}`}>
<StaticLink href={`/products/${product.id}`}>
<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">
@@ -130,7 +85,7 @@ export function ProductsSection({ config }: ProductsSectionProps) {
</ul>
</div>
{config?.showPricing && product.pricing && (
{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">
@@ -149,7 +104,7 @@ export function ProductsSection({ config }: ProductsSectionProps) {
</Button>
</CardContent>
</Card>
</Link>
</StaticLink>
</motion.div>
))}
</div>
@@ -181,10 +136,10 @@ export function ProductsSection({ config }: ProductsSectionProps) {
size="lg"
asChild
>
<Link href="/contact">
<StaticLink href="/contact">
<ArrowRight className="ml-2 w-4 h-4" />
</Link>
</StaticLink>
</Button>
</div>
</div>