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
@@ -1,10 +1,10 @@
'use client';
import Link from 'next/link';
import { StaticLink } from '@/components/ui/static-link';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { BackButton } from '@/components/ui/back-button';
import { Calendar } from 'lucide-react';
import { Calendar, ArrowLeft } from 'lucide-react';
import { motion } from 'framer-motion';
import { useInView } from 'framer-motion';
import { useRef } from 'react';
@@ -72,7 +72,7 @@ export function NewsDetailClient({ news }: NewsDetailClientProps) {
</h2>
<div className="grid md:grid-cols-3 gap-6">
{relatedNews.map((related) => (
<Link key={related.id} href={`/news/${related.id}`}>
<StaticLink key={related.id} href={`/news/${related.id}`}>
<div className="group cursor-pointer">
<div className="aspect-video bg-linear-to-br from-[#C41E3A]/10 to-[#1C1C1C]/10 rounded-lg mb-4 flex items-center justify-center group-hover:shadow-lg transition-shadow">
<span className="text-4xl">📰</span>
@@ -87,23 +87,24 @@ export function NewsDetailClient({ news }: NewsDetailClientProps) {
{related.excerpt}
</p>
</div>
</Link>
</StaticLink>
))}
</div>
</div>
)}
<div className="mt-16 flex justify-center gap-4">
<Link href="/news">
<StaticLink href="/news">
<Button variant="outline" size="lg">
<ArrowLeft className="w-4 h-4 mr-2" />
返回新闻列表
</Button>
</Link>
<Link href="/contact">
</StaticLink>
<StaticLink href="/contact">
<Button size="lg" className="bg-[#C41E3A] hover:bg-[#A01830] text-white">
联系我们
</Button>
</Link>
</StaticLink>
</div>
</motion.div>
</div>
+9 -40
View File
@@ -2,14 +2,14 @@
import { useState, useMemo, useRef, ChangeEvent } from 'react';
import { useInView } from 'framer-motion';
import { useNews } from '@/hooks/use-news';
import { NEWS } from '@/lib/constants';
import { Card, CardContent } from '@/components/ui/card';
import { Badge } from '@/components/ui/badge';
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { PageHeader } from '@/components/ui/page-header';
import { Search, Calendar, ArrowLeft, Filter, ChevronLeft, ChevronRight, ArrowRight } from 'lucide-react';
import Link from 'next/link';
import { Search, Calendar, Filter, ChevronLeft, ChevronRight, ArrowRight } from 'lucide-react';
import { StaticLink } from '@/components/ui/static-link';
import { motion } from 'framer-motion';
const categories = ['全部', '公司新闻', '产品发布', '合作动态', '行业资讯'];
@@ -21,19 +21,15 @@ export default function NewsListPage() {
const [currentPage, setCurrentPage] = useState(1);
const contentRef = useRef(null);
const isContentInView = useInView(contentRef, { once: true, margin: '-100px' });
const { news, loading, error } = useNews();
const filteredNews = useMemo(() => {
if (!news || news.length === 0) {return [];}
return news.filter((newsItem) => {
return NEWS.filter((newsItem) => {
const matchesCategory = selectedCategory === '全部' || newsItem.category === selectedCategory;
const matchesSearch =
const matchesSearch =
newsItem.title.toLowerCase().includes(searchQuery.toLowerCase()) ||
newsItem.excerpt.toLowerCase().includes(searchQuery.toLowerCase());
return matchesCategory && matchesSearch;
});
}, [news, selectedCategory, searchQuery]);
}, [selectedCategory, searchQuery]);
const totalPages = Math.ceil(filteredNews.length / ITEMS_PER_PAGE);
const paginatedNews = useMemo(() => {
@@ -57,28 +53,6 @@ export default function NewsListPage() {
setCurrentPage(1);
};
if (loading) {
return (
<div className="min-h-screen bg-white flex items-center justify-center">
<div className="text-center">
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-[#C41E3A] mx-auto mb-4" />
<p className="text-[#5C5C5C]">加载中...</p>
</div>
</div>
);
}
if (error) {
return (
<div className="min-h-screen bg-white flex items-center justify-center">
<div className="text-center">
<p className="text-red-600 mb-4">加载新闻失败</p>
<Button onClick={() => window.location.reload()}>重新加载</Button>
</div>
</div>
);
}
return (
<div className="min-h-screen bg-white">
<PageHeader
@@ -87,12 +61,7 @@ export default function NewsListPage() {
/>
<div className="container-wide relative z-10 py-12" ref={contentRef}>
<Link href="/" className="inline-flex items-center text-[#5C5C5C] hover:text-[#C41E3A] transition-colors mb-8">
<ArrowLeft className="w-4 h-4 mr-2" />
返回首页
</Link>
<motion.div
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={isContentInView ? { opacity: 1, y: 0 } : {}}
transition={{ duration: 0.6 }}
@@ -147,7 +116,7 @@ export default function NewsListPage() {
animate={isContentInView ? { opacity: 1, y: 0 } : {}}
transition={{ duration: 0.5, delay: 0.2 + index * 0.1 }}
>
<Link href={`/news/${newsItem.id}`}>
<StaticLink href={`/news/${newsItem.id}`}>
<Card className="h-full hover:shadow-lg transition-shadow cursor-pointer border-[#E5E5E5] hover:border-[#C41E3A]">
<CardContent className="p-0">
{newsItem.image ? (
@@ -184,7 +153,7 @@ export default function NewsListPage() {
</div>
</CardContent>
</Card>
</Link>
</StaticLink>
</motion.div>
))}
</div>