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 -64
View File
@@ -2,72 +2,19 @@
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 { ArrowRight, Calendar } from 'lucide-react';
import { useNews } from '@/hooks/use-news';
import { NEWS } from '@/lib/constants';
interface NewsConfig {
enabled?: boolean;
displayCount?: number;
categories?: string[];
sortOrder?: 'asc' | 'desc';
}
interface NewsSectionProps {
config?: NewsConfig;
}
export function NewsSection({ config }: NewsSectionProps) {
export function NewsSection() {
const ref = useRef(null);
const isInView = useInView(ref, { once: true, margin: '-100px' });
const { news, loading, error } = useNews();
const displayedNews = useMemo(() => {
if (!news || news.length === 0) {
return [];
}
let filtered = news;
if (config?.categories && config.categories.length > 0) {
filtered = filtered.filter(newsItem => config.categories?.includes(newsItem.category));
}
if (config?.sortOrder === 'asc') {
filtered = [...filtered].sort((a, b) => new Date(a.date).getTime() - new Date(b.date).getTime());
} else {
filtered = [...filtered].sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
}
const count = config?.displayCount || 4;
return filtered.slice(0, count);
}, [news, config]);
if (loading) {
return (
<section id="news" role="region" aria-labelledby="news-heading" className="py-24 bg-[#F5F5F5]" ref={ref}>
<div className="container-custom">
<div className="text-center">
<p className="text-lg text-[#5C5C5C]">...</p>
</div>
</div>
</section>
);
}
if (error) {
return (
<section id="news" role="region" aria-labelledby="news-heading" className="py-24 bg-[#F5F5F5]" ref={ref}>
<div className="container-custom">
<div className="text-center">
<p className="text-lg text-red-600"></p>
</div>
</div>
</section>
);
}
const displayedNews = [...NEWS]
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
.slice(0, 4);
return (
<section id="news" role="region" aria-labelledby="news-heading" className="py-24 bg-[#F5F5F5]" ref={ref}>
@@ -112,13 +59,13 @@ export function NewsSection({ config }: NewsSectionProps) {
<CardDescription className="text-base leading-relaxed mb-6 flex-1">
{newsItem.excerpt}
</CardDescription>
<Link
<StaticLink
href={`/news/${newsItem.id}`}
className="inline-flex items-center text-sm font-medium text-[#1C1C1C] hover:text-[#C41E3A] transition-colors group/link"
>
<ArrowRight className="ml-1 w-4 h-4 transition-transform group-hover/link:translate-x-1" />
</Link>
</StaticLink>
</CardContent>
</Card>
</motion.div>
@@ -136,13 +83,13 @@ export function NewsSection({ config }: NewsSectionProps) {
transition={{ duration: 0.6, delay: 0.5 }}
className="mt-12 text-center"
>
<Link
<StaticLink
href="/news"
className="inline-flex items-center text-sm font-medium text-[#1C1C1C] hover:text-[#C41E3A] transition-colors bg-transparent border-none cursor-pointer group"
>
<ArrowRight className="ml-1 w-4 h-4 transition-transform group-hover:translate-x-1" />
</Link>
</StaticLink>
</motion.div>
</div>
</section>