From 4ad505cda12ec99efbb40fee70f28db1e852999a Mon Sep 17 00:00:00 2001 From: William Tso Date: Wed, 26 Mar 2025 21:50:04 +0800 Subject: [PATCH] fix build --- app/(app)/links/page.tsx | 30 ++++++++++++++++++++++++++++-- app/(swagger)/swagger/page.tsx | 13 ++++++++++++- lib/analytics.ts | 8 ++++++++ next.config.js | 13 ------------- next.config.ts | 6 +++--- 5 files changed, 51 insertions(+), 19 deletions(-) delete mode 100644 next.config.js diff --git a/app/(app)/links/page.tsx b/app/(app)/links/page.tsx index 550f6ad..2e2c6e8 100644 --- a/app/(app)/links/page.tsx +++ b/app/(app)/links/page.tsx @@ -1,8 +1,34 @@ "use client"; import { useState, useEffect, useCallback, useRef } from 'react'; -import CreateLinkModal from '../components/ui/CreateLinkModal'; -import { Link, StatsOverview, Tag } from '../api/types'; +import CreateLinkModal from '@/app/components/ui/CreateLinkModal'; + +// 自定义类型定义,替换原来的导入 +interface Link { + link_id: string; + title?: string; + original_url: string; + visits: number; + unique_visits: number; + created_by: string; + created_at: string; + is_active: boolean; + tags?: string[]; +} + +interface StatsOverview { + totalLinks: number; + activeLinks: number; + totalVisits: number; + conversionRate: number; +} + +interface Tag { + tag: string; + id: string; + name: string; + count: number; +} // Define type for link data interface LinkData { diff --git a/app/(swagger)/swagger/page.tsx b/app/(swagger)/swagger/page.tsx index ae92542..8c232dc 100644 --- a/app/(swagger)/swagger/page.tsx +++ b/app/(swagger)/swagger/page.tsx @@ -2,12 +2,23 @@ import { useEffect } from 'react'; import SwaggerUI from 'swagger-ui-react'; -import 'swagger-ui-react/swagger-ui.css'; export default function SwaggerPage() { useEffect(() => { // 设置页面标题 document.title = 'API Documentation - ShortURL Analytics'; + + // 动态添加Swagger UI CSS + const link = document.createElement('link'); + link.rel = 'stylesheet'; + link.type = 'text/css'; + link.href = 'https://unpkg.com/swagger-ui-dist@5.20.1/swagger-ui.css'; + document.head.appendChild(link); + + // 清理函数 + return () => { + document.head.removeChild(link); + }; }, []); // Swagger配置 diff --git a/lib/analytics.ts b/lib/analytics.ts index 6232617..168c8b2 100644 --- a/lib/analytics.ts +++ b/lib/analytics.ts @@ -1,6 +1,14 @@ import { executeQuery, executeQuerySingle, buildFilter, buildPagination, buildOrderBy } from './clickhouse'; import type { Event, EventsSummary, TimeSeriesData, GeoData, DeviceAnalytics, DeviceType } from './types'; +// 时间粒度枚举 +export enum TimeGranularity { + HOUR = 'hour', + DAY = 'day', + WEEK = 'week', + MONTH = 'month' +} + // 获取事件列表 export async function getEvents(params: { startTime?: string; diff --git a/next.config.js b/next.config.js deleted file mode 100644 index 37dc9e8..0000000 --- a/next.config.js +++ /dev/null @@ -1,13 +0,0 @@ -/** @type {import('next').NextConfig} */ -const nextConfig = { - transpilePackages: ['swagger-ui-react'], - webpack: (config) => { - config.module.rules.push({ - test: /\.css$/, - use: ['style-loader', 'css-loader'], - }); - return config; - }, -}; - -module.exports = nextConfig; \ No newline at end of file diff --git a/next.config.ts b/next.config.ts index 9855a71..75c5a22 100644 --- a/next.config.ts +++ b/next.config.ts @@ -3,7 +3,7 @@ import type { NextConfig } from "next"; const nextConfig: NextConfig = { /* config options here */ // 设置需要转译的包 - transpilePackages: [], + transpilePackages: ['swagger-ui-react'], // 配置实验性选项 experimental: { @@ -14,8 +14,8 @@ const nextConfig: NextConfig = { // 禁用严格模式,避免开发时重复渲染 reactStrictMode: false, - // 设置输出为独立应用 - output: 'standalone', + // 暂时禁用standalone输出模式,解决构建问题 + // output: 'standalone', // 忽略ESLint错误,不会在构建时中断 eslint: {