rm dark
This commit is contained in:
@@ -92,7 +92,7 @@ export default function GeoAnalyticsPage() {
|
|||||||
<td className="px-6 py-4 whitespace-nowrap text-sm">
|
<td className="px-6 py-4 whitespace-nowrap text-sm">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<span className="mr-2 text-foreground">{item.percentage.toFixed(1)}%</span>
|
<span className="mr-2 text-foreground">{item.percentage.toFixed(1)}%</span>
|
||||||
<div className="w-24 bg-gray-200 dark:bg-gray-700 rounded-full h-2">
|
<div className="w-24 bg-gray-200 rounded-full h-2">
|
||||||
<div
|
<div
|
||||||
className="bg-blue-500 h-2 rounded-full"
|
className="bg-blue-500 h-2 rounded-full"
|
||||||
style={{ width: `${item.percentage}%` }}
|
style={{ width: `${item.percentage}%` }}
|
||||||
|
|||||||
@@ -4,51 +4,51 @@ export default function Home() {
|
|||||||
return (
|
return (
|
||||||
<div className="container mx-auto px-4">
|
<div className="container mx-auto px-4">
|
||||||
<div className="max-w-2xl mx-auto py-16">
|
<div className="max-w-2xl mx-auto py-16">
|
||||||
<h1 className="text-4xl font-bold text-gray-900 dark:text-gray-100 mb-8">
|
<h1 className="text-4xl font-bold text-gray-900 mb-8">
|
||||||
Welcome to ShortURL Analytics
|
Welcome to ShortURL Analytics
|
||||||
</h1>
|
</h1>
|
||||||
<div className="grid gap-6">
|
<div className="grid gap-6">
|
||||||
<Link
|
<Link
|
||||||
href="/dashboard"
|
href="/dashboard"
|
||||||
className="block p-6 bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-shadow"
|
className="block p-6 bg-white rounded-lg shadow hover:shadow-md transition-shadow"
|
||||||
>
|
>
|
||||||
<h2 className="text-xl font-semibold text-gray-900 dark:text-gray-100 mb-2">
|
<h2 className="text-xl font-semibold text-gray-900 mb-2">
|
||||||
Dashboard
|
Dashboard
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-gray-600 dark:text-gray-400">
|
<p className="text-gray-600">
|
||||||
View your overall analytics and key metrics
|
View your overall analytics and key metrics
|
||||||
</p>
|
</p>
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
href="/events"
|
href="/events"
|
||||||
className="block p-6 bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-shadow"
|
className="block p-6 bg-white rounded-lg shadow hover:shadow-md transition-shadow"
|
||||||
>
|
>
|
||||||
<h2 className="text-xl font-semibold text-gray-900 dark:text-gray-100 mb-2">
|
<h2 className="text-xl font-semibold text-gray-900 mb-2">
|
||||||
Events
|
Events
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-gray-600 dark:text-gray-400">
|
<p className="text-gray-600">
|
||||||
Track and analyze event data
|
Track and analyze event data
|
||||||
</p>
|
</p>
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
href="/analytics/geo"
|
href="/analytics/geo"
|
||||||
className="block p-6 bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-shadow"
|
className="block p-6 bg-white rounded-lg shadow hover:shadow-md transition-shadow"
|
||||||
>
|
>
|
||||||
<h2 className="text-xl font-semibold text-gray-900 dark:text-gray-100 mb-2">
|
<h2 className="text-xl font-semibold text-gray-900 mb-2">
|
||||||
Geographic Analysis
|
Geographic Analysis
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-gray-600 dark:text-gray-400">
|
<p className="text-gray-600">
|
||||||
Explore visitor locations and geographic patterns
|
Explore visitor locations and geographic patterns
|
||||||
</p>
|
</p>
|
||||||
</Link>
|
</Link>
|
||||||
<Link
|
<Link
|
||||||
href="/analytics/devices"
|
href="/analytics/devices"
|
||||||
className="block p-6 bg-white dark:bg-gray-800 rounded-lg shadow hover:shadow-md transition-shadow"
|
className="block p-6 bg-white rounded-lg shadow hover:shadow-md transition-shadow"
|
||||||
>
|
>
|
||||||
<h2 className="text-xl font-semibold text-gray-900 dark:text-gray-100 mb-2">
|
<h2 className="text-xl font-semibold text-gray-900 mb-2">
|
||||||
Device Analytics
|
Device Analytics
|
||||||
</h2>
|
</h2>
|
||||||
<p className="text-gray-600 dark:text-gray-400">
|
<p className="text-gray-600">
|
||||||
Understand how users access your links
|
Understand how users access your links
|
||||||
</p>
|
</p>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,8 +1,20 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import SwaggerUI from 'swagger-ui-react';
|
|
||||||
import 'swagger-ui-react/swagger-ui.css';
|
// 动态导入,避免生产环境问题
|
||||||
|
let SwaggerUI = () => <div>Swagger UI is not available in production</div>;
|
||||||
|
let swaggerCss = null;
|
||||||
|
|
||||||
|
// 只在开发环境中导入 Swagger UI
|
||||||
|
if (process.env.NODE_ENV === 'development') {
|
||||||
|
try {
|
||||||
|
SwaggerUI = require('swagger-ui-react').default;
|
||||||
|
require('swagger-ui-react/swagger-ui.css');
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to load Swagger UI:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default function SwaggerPage() {
|
export default function SwaggerPage() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -10,6 +22,21 @@ export default function SwaggerPage() {
|
|||||||
document.title = 'API Documentation - ShortURL Analytics';
|
document.title = 'API Documentation - ShortURL Analytics';
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
// 生产环境显示替代内容
|
||||||
|
if (process.env.NODE_ENV !== 'development') {
|
||||||
|
return (
|
||||||
|
<div className="p-8 max-w-4xl mx-auto">
|
||||||
|
<h1 className="text-2xl font-bold mb-4">API Documentation</h1>
|
||||||
|
<p className="mb-4">
|
||||||
|
Swagger UI is only available in development environment.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Please run the application in development mode to access the full API documentation.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Swagger配置
|
// Swagger配置
|
||||||
const swaggerConfig = {
|
const swaggerConfig = {
|
||||||
openapi: '3.0.0',
|
openapi: '3.0.0',
|
||||||
|
|||||||
@@ -22,16 +22,16 @@ function StatCard({ title, items }: { title: string; items: { name: string; coun
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-white dark:bg-gray-800 rounded-lg shadow p-6">
|
<div className="bg-white rounded-lg shadow p-6">
|
||||||
<h3 className="text-lg font-semibold text-gray-900 dark:text-gray-100 mb-4">{title}</h3>
|
<h3 className="text-lg font-semibold text-gray-900 mb-4">{title}</h3>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
{items.map((item, index) => (
|
{items.map((item, index) => (
|
||||||
<div key={index}>
|
<div key={index}>
|
||||||
<div className="flex justify-between text-sm text-gray-600 dark:text-gray-400 mb-1">
|
<div className="flex justify-between text-sm text-gray-600 mb-1">
|
||||||
<span>{item.name || 'Unknown'}</span>
|
<span>{item.name || 'Unknown'}</span>
|
||||||
<span>{formatNumber(item.count)} ({formatPercent(item.percentage)}%)</span>
|
<span>{formatNumber(item.count)} ({formatPercent(item.percentage)}%)</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="w-full bg-gray-200 dark:bg-gray-700 rounded-full h-2">
|
<div className="w-full bg-gray-200 rounded-full h-2">
|
||||||
<div
|
<div
|
||||||
className="bg-blue-500 h-2 rounded-full"
|
className="bg-blue-500 h-2 rounded-full"
|
||||||
style={{ width: `${item.percentage || 0}%` }}
|
style={{ width: `${item.percentage || 0}%` }}
|
||||||
|
|||||||
@@ -23,39 +23,39 @@ export default function GeoAnalytics({ data }: GeoAnalyticsProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="overflow-x-auto">
|
<div className="overflow-x-auto">
|
||||||
<table className="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
<table className="min-w-full divide-y divide-gray-200">
|
||||||
<thead className="bg-gray-50 dark:bg-gray-800">
|
<thead className="bg-gray-50">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
Location
|
Location
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
Visits
|
Visits
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
Unique Visitors
|
Unique Visitors
|
||||||
</th>
|
</th>
|
||||||
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider">
|
<th scope="col" className="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
|
||||||
Percentage
|
Percentage
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody className="bg-white dark:bg-gray-900 divide-y divide-gray-200 dark:divide-gray-700">
|
<tbody className="bg-white divide-y divide-gray-200">
|
||||||
{data.map((item, index) => (
|
{data.map((item, index) => (
|
||||||
<tr key={index} className={index % 2 === 0 ? 'bg-white dark:bg-gray-900' : 'bg-gray-50 dark:bg-gray-800'}>
|
<tr key={index} className={index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}>
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-gray-100">
|
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||||
{item.city ? `${item.city}, ${item.region}, ${item.country}` : item.region ? `${item.region}, ${item.country}` : item.country || item.location || 'Unknown'}
|
{item.city ? `${item.city}, ${item.region}, ${item.country}` : item.region ? `${item.region}, ${item.country}` : item.country || item.location || 'Unknown'}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-gray-100">
|
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||||
{formatNumber(item.visits)}
|
{formatNumber(item.visits)}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-gray-100">
|
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||||
{formatNumber(item.uniqueVisitors || item.visitors)}
|
{formatNumber(item.uniqueVisitors || item.visitors)}
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900 dark:text-gray-100">
|
<td className="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center">
|
||||||
<span className="mr-2">{formatPercent(item.percentage)}%</span>
|
<span className="mr-2">{formatPercent(item.percentage)}%</span>
|
||||||
<div className="w-24 bg-gray-200 dark:bg-gray-700 rounded-full h-2">
|
<div className="w-24 bg-gray-200 rounded-full h-2">
|
||||||
<div
|
<div
|
||||||
className="bg-blue-500 h-2 rounded-full"
|
className="bg-blue-500 h-2 rounded-full"
|
||||||
style={{ width: `${item.percentage || 0}%` }}
|
style={{ width: `${item.percentage || 0}%` }}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export function DateRangePicker({ value, onChange }: DateRangePickerProps) {
|
|||||||
return (
|
return (
|
||||||
<div className="flex items-center space-x-4">
|
<div className="flex items-center space-x-4">
|
||||||
<div>
|
<div>
|
||||||
<label htmlFor="from" className="block text-sm font-medium text-gray-500 dark:text-gray-400 mb-1">
|
<label htmlFor="from" className="block text-sm font-medium text-gray-500 mb-1">
|
||||||
From
|
From
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
@@ -50,11 +50,11 @@ export function DateRangePicker({ value, onChange }: DateRangePickerProps) {
|
|||||||
value={from}
|
value={from}
|
||||||
onChange={handleFromChange}
|
onChange={handleFromChange}
|
||||||
max={to}
|
max={to}
|
||||||
className="block w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md text-sm text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
className="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md text-sm text-gray-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label htmlFor="to" className="block text-sm font-medium text-gray-500 dark:text-gray-400 mb-1">
|
<label htmlFor="to" className="block text-sm font-medium text-gray-500 mb-1">
|
||||||
To
|
To
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
@@ -63,7 +63,7 @@ export function DateRangePicker({ value, onChange }: DateRangePickerProps) {
|
|||||||
value={to}
|
value={to}
|
||||||
onChange={handleToChange}
|
onChange={handleToChange}
|
||||||
min={from}
|
min={from}
|
||||||
className="block w-full px-3 py-2 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-md text-sm text-gray-900 dark:text-gray-100 focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
className="block w-full px-3 py-2 bg-white border border-gray-300 rounded-md text-sm text-gray-900 focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ export default function RootLayout({
|
|||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}>) {
|
}>) {
|
||||||
return (
|
return (
|
||||||
<html lang="en" suppressHydrationWarning>
|
<html lang="en" className="light" suppressHydrationWarning>
|
||||||
<body>
|
<body>
|
||||||
{children}
|
{children}
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
14
app/page.tsx
14
app/page.tsx
@@ -48,10 +48,10 @@ export default function HomePage() {
|
|||||||
<div className="container mx-auto px-4">
|
<div className="container mx-auto px-4">
|
||||||
<div className="max-w-4xl mx-auto">
|
<div className="max-w-4xl mx-auto">
|
||||||
<div className="text-center mb-12">
|
<div className="text-center mb-12">
|
||||||
<h1 className="text-4xl font-bold text-gray-900 dark:text-gray-100 mb-4">
|
<h1 className="text-4xl font-bold text-gray-900 mb-4">
|
||||||
Welcome to ShortURL Analytics
|
Welcome to ShortURL Analytics
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-lg text-gray-600 dark:text-gray-400">
|
<p className="text-lg text-gray-600">
|
||||||
Get detailed insights into your link performance and visitor behavior
|
Get detailed insights into your link performance and visitor behavior
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
@@ -61,19 +61,19 @@ export default function HomePage() {
|
|||||||
<Link
|
<Link
|
||||||
key={section.title}
|
key={section.title}
|
||||||
href={section.href}
|
href={section.href}
|
||||||
className="group block p-6 bg-white dark:bg-gray-800 rounded-lg shadow-sm hover:shadow-md transition-shadow duration-200"
|
className="group block p-6 bg-white rounded-lg shadow-sm hover:shadow-md transition-shadow duration-200"
|
||||||
>
|
>
|
||||||
<div className="flex items-center mb-4">
|
<div className="flex items-center mb-4">
|
||||||
<div className="p-2 bg-blue-100 dark:bg-blue-900 rounded-lg mr-4">
|
<div className="p-2 bg-blue-100 rounded-lg mr-4">
|
||||||
<div className="text-blue-600 dark:text-blue-300">
|
<div className="text-blue-600">
|
||||||
{section.icon}
|
{section.icon}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h2 className="text-xl font-semibold text-gray-900 dark:text-gray-100 group-hover:text-blue-600 dark:group-hover:text-blue-400 transition-colors duration-200">
|
<h2 className="text-xl font-semibold text-gray-900 group-hover:text-blue-600 transition-colors duration-200">
|
||||||
{section.title}
|
{section.title}
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-gray-600 dark:text-gray-400">
|
<p className="text-gray-600">
|
||||||
{section.description}
|
{section.description}
|
||||||
</p>
|
</p>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -1,18 +1,33 @@
|
|||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
// 启用 webpack 配置
|
// 设置需要转译的包
|
||||||
webpack: (config) => {
|
transpilePackages: ['swagger-ui-react'],
|
||||||
|
|
||||||
|
// 禁用严格模式,避免开发时重复渲染
|
||||||
|
reactStrictMode: false,
|
||||||
|
|
||||||
|
webpack: (config, { dev }) => {
|
||||||
// 添加 CSS 处理规则
|
// 添加 CSS 处理规则
|
||||||
config.module.rules.push({
|
config.module.rules.push({
|
||||||
test: /\.css$/,
|
test: /\.css$/,
|
||||||
type: 'asset/source',
|
type: 'asset/source',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 仅在生产环境中排除 Swagger
|
||||||
|
if (!dev) {
|
||||||
|
config.resolve.alias = {
|
||||||
|
...config.resolve.alias,
|
||||||
|
'swagger-ui-react': false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
},
|
},
|
||||||
|
|
||||||
eslint: {
|
eslint: {
|
||||||
ignoreDuringBuilds: true,
|
ignoreDuringBuilds: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
typescript: {
|
typescript: {
|
||||||
ignoreBuildErrors: true,
|
ignoreBuildErrors: true,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
import type { NextConfig } from "next";
|
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
|
||||||
/* config options here */
|
|
||||||
// 设置需要转译的包
|
|
||||||
transpilePackages: ['swagger-ui-react'],
|
|
||||||
|
|
||||||
// 配置实验性选项
|
|
||||||
experimental: {
|
|
||||||
// 禁用外部目录处理,避免monorepo问题
|
|
||||||
// externalDir: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
// 禁用严格模式,避免开发时重复渲染
|
|
||||||
reactStrictMode: false,
|
|
||||||
|
|
||||||
// 暂时禁用standalone输出模式,解决构建问题
|
|
||||||
// output: 'standalone',
|
|
||||||
|
|
||||||
// 忽略ESLint错误,不会在构建时中断
|
|
||||||
eslint: {
|
|
||||||
ignoreDuringBuilds: true,
|
|
||||||
},
|
|
||||||
|
|
||||||
// 忽略TypeScript错误,不会在构建时中断
|
|
||||||
typescript: {
|
|
||||||
ignoreBuildErrors: true,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export default nextConfig;
|
|
||||||
@@ -6,6 +6,7 @@ const config: Config = {
|
|||||||
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
"./components/**/*.{js,ts,jsx,tsx,mdx}",
|
||||||
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
"./app/**/*.{js,ts,jsx,tsx,mdx}",
|
||||||
],
|
],
|
||||||
|
darkMode: "class",
|
||||||
theme: {
|
theme: {
|
||||||
extend: {
|
extend: {
|
||||||
colors: {
|
colors: {
|
||||||
|
|||||||
Reference in New Issue
Block a user