fix build

This commit is contained in:
2025-03-26 21:50:04 +08:00
parent 7a03396cdd
commit 4ad505cda1
5 changed files with 51 additions and 19 deletions

View File

@@ -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 {

View File

@@ -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配置

View File

@@ -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;

View File

@@ -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;

View File

@@ -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: {