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
+2 -10
View File
@@ -1,16 +1,10 @@
'use client';
import Script from 'next/script';
import { useEffect } from 'react';
import { GA_MEASUREMENT_ID } from '@/lib/analytics';
const GA_MEASUREMENT_ID = process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID || '';
export function GoogleAnalytics() {
useEffect(() => {
if (GA_MEASUREMENT_ID) {
console.log('Google Analytics initialized:', GA_MEASUREMENT_ID);
}
}, []);
if (!GA_MEASUREMENT_ID) {
return null;
}
@@ -25,10 +19,8 @@ export function GoogleAnalytics() {
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
window.gtag = gtag;
gtag('js', new Date());
gtag('config', '${GA_MEASUREMENT_ID}', {
page_path: window.location.pathname,
send_page_view: false
});
`}
@@ -1,21 +0,0 @@
import '@testing-library/jest-dom';
jest.mock('./GoogleAnalytics', () => ({
GoogleAnalytics: () => null,
}));
jest.mock('./web-vitals', () => ({
WebVitals: () => null,
}));
describe('Analytics Components', () => {
it('should export GoogleAnalytics', () => {
const { GoogleAnalytics } = require('./GoogleAnalytics');
expect(GoogleAnalytics).toBeDefined();
});
it('should export WebVitals', () => {
const { WebVitals } = require('./web-vitals');
expect(WebVitals).toBeDefined();
});
});
-33
View File
@@ -1,33 +0,0 @@
'use client';
import { useReportWebVitals } from 'next/web-vitals';
export function WebVitals() {
useReportWebVitals((metric) => {
if (process.env.NODE_ENV === 'development') {
console.log('[Web Vitals]', metric);
}
if (process.env.NODE_ENV === 'production') {
const body = JSON.stringify({
name: metric.name,
value: metric.value,
rating: metric.rating,
delta: metric.delta,
id: metric.id,
});
if (navigator.sendBeacon) {
navigator.sendBeacon('/api/analytics', body);
} else {
fetch('/api/analytics', {
body,
method: 'POST',
keepalive: true,
}).catch(() => {});
}
}
});
return null;
}