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
+13 -57
View File
@@ -2,67 +2,23 @@
import { motion } from 'framer-motion';
import { useInView } from 'framer-motion';
import { useRef, useMemo } from 'react';
import Link from 'next/link';
import { Code, Cloud, BarChart3, Shield, ArrowRight } from 'lucide-react';
import { useRef } from 'react';
import { StaticLink } from '@/components/ui/static-link';
import { Code, BarChart3, Lightbulb, Puzzle, ArrowRight } from 'lucide-react';
import { Card, CardContent } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
import { useServices } from '@/hooks/use-services';
import { SERVICES } from '@/lib/constants';
const iconMap: Record<string, React.ComponentType<{ className?: string }>> = {
Code,
Cloud,
BarChart3,
Shield,
Lightbulb,
Puzzle,
};
interface ServicesConfig {
enabled?: boolean;
items?: string[];
}
interface ServicesSectionProps {
config?: ServicesConfig;
}
export function ServicesSection({ config }: ServicesSectionProps) {
export function ServicesSection() {
const ref = useRef(null);
const isInView = useInView(ref, { once: true, margin: '-100px' });
const { services, loading, error } = useServices();
const filteredServices = useMemo(() => {
if (!services || services.length === 0) {
return [];
}
if (!config?.items || config.items.length === 0) {
return services;
}
return services.filter(service => config.items?.includes(service.id));
}, [services, config]);
if (loading) {
return (
<section id="services" aria-labelledby="services-heading" className="py-24 bg-white relative overflow-hidden" ref={ref}>
<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="services" aria-labelledby="services-heading" className="py-24 bg-white relative overflow-hidden" ref={ref}>
<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="services" aria-labelledby="services-heading" className="py-24 bg-white relative overflow-hidden" ref={ref}>
@@ -84,9 +40,9 @@ export function ServicesSection({ config }: ServicesSectionProps) {
</p>
</motion.div>
{filteredServices.length > 0 ? (
{SERVICES.length > 0 ? (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
{filteredServices.map((service, index) => {
{SERVICES.map((service, index) => {
const Icon = iconMap[service.icon];
return (
<motion.div
@@ -96,7 +52,7 @@ export function ServicesSection({ config }: ServicesSectionProps) {
viewport={{ once: true }}
transition={{ duration: 0.5, delay: index * 0.1 }}
>
<Link href={`/services/${service.id}`}>
<StaticLink href={`/services/${service.id}`}>
<Card className="p-6 h-full group cursor-pointer border-[#E5E5E5] hover:border-[#C41E3A] transition-colors">
<CardContent className="p-0">
<div className="w-12 h-12 rounded-xl bg-[#F5F5F5] flex items-center justify-center mb-4 group-hover:bg-[#C41E3A] transition-all duration-300">
@@ -110,7 +66,7 @@ export function ServicesSection({ config }: ServicesSectionProps) {
</div>
</CardContent>
</Card>
</Link>
</StaticLink>
</motion.div>
);
})}
@@ -128,10 +84,10 @@ export function ServicesSection({ config }: ServicesSectionProps) {
className="text-center mt-12"
>
<Button variant="outline" size="lg" className="group" asChild>
<Link href="/services">
<StaticLink href="/services">
<ArrowRight className="ml-2 w-4 h-4 transition-transform group-hover:translate-x-1" />
</Link>
</StaticLink>
</Button>
</motion.div>
</div>