diff --git a/app/analytics/devices/page.tsx b/app/(app)/analytics/devices/page.tsx similarity index 99% rename from app/analytics/devices/page.tsx rename to app/(app)/analytics/devices/page.tsx index 9bc0076..6d7779f 100644 --- a/app/analytics/devices/page.tsx +++ b/app/(app)/analytics/devices/page.tsx @@ -1,7 +1,8 @@ "use client"; import { useState, useEffect, useRef } from 'react'; -import { DeviceAnalytics } from '../../api/types'; +import { fetchData } from '@/app/api/utils'; +import { DeviceAnalytics } from '@/app/api/types'; import { Chart, PieController, ArcElement, Tooltip, Legend, CategoryScale, LinearScale } from 'chart.js'; // 注册Chart.js组件 diff --git a/app/analytics/geo/page.tsx b/app/(app)/analytics/geo/page.tsx similarity index 100% rename from app/analytics/geo/page.tsx rename to app/(app)/analytics/geo/page.tsx diff --git a/app/dashboard/page.tsx b/app/(app)/dashboard/page.tsx similarity index 94% rename from app/dashboard/page.tsx rename to app/(app)/dashboard/page.tsx index 4704fa5..7739b1f 100644 --- a/app/dashboard/page.tsx +++ b/app/(app)/dashboard/page.tsx @@ -2,11 +2,11 @@ import { useState, useEffect } from 'react'; import { addDays, format } from 'date-fns'; -import { DateRangePicker } from '../components/ui/DateRangePicker'; -import TimeSeriesChart from '../components/charts/TimeSeriesChart'; -import GeoAnalytics from '../components/analytics/GeoAnalytics'; -import DeviceAnalytics from '../components/analytics/DeviceAnalytics'; -import { EventsSummary, TimeSeriesData, GeoData, DeviceAnalytics as DeviceAnalyticsType } from '../api/types'; +import { DateRangePicker } from '@/app/components/ui/DateRangePicker'; +import TimeSeriesChart from '@/app/components/charts/TimeSeriesChart'; +import GeoAnalytics from '@/app/components/analytics/GeoAnalytics'; +import DeviceAnalytics from '@/app/components/analytics/DeviceAnalytics'; +import { EventsSummary, TimeSeriesData, GeoData, DeviceAnalytics as DeviceAnalyticsType } from '@/app/api/types'; export default function DashboardPage() { const [dateRange, setDateRange] = useState({ diff --git a/app/events/page.tsx b/app/(app)/events/page.tsx similarity index 98% rename from app/events/page.tsx rename to app/(app)/events/page.tsx index 90feabf..d2cd00c 100644 --- a/app/events/page.tsx +++ b/app/(app)/events/page.tsx @@ -1,9 +1,9 @@ "use client"; import { useState, useEffect } from 'react'; -import { format } from 'date-fns'; -import { DateRangePicker } from '../components/ui/DateRangePicker'; -import { Event } from '../api/types'; +import { addDays, format } from 'date-fns'; +import { DateRangePicker } from '@/app/components/ui/DateRangePicker'; +import { Event } from '@/app/api/types'; export default function EventsPage() { const [dateRange, setDateRange] = useState({ diff --git a/app/(app)/layout.tsx b/app/(app)/layout.tsx new file mode 100644 index 0000000..6dea6a1 --- /dev/null +++ b/app/(app)/layout.tsx @@ -0,0 +1,66 @@ +import '../globals.css'; +import type { Metadata } from 'next'; +import { Inter } from 'next/font/google'; +import Link from 'next/link'; + +const inter = Inter({ subsets: ['latin'] }); + +export const metadata: Metadata = { + title: 'ShortURL Analytics', + description: 'Analytics dashboard for ShortURL service', +}; + +export default function AppLayout({ + children, +}: { + children: React.ReactNode; +}) { + return ( +
+
+ +
+ {children} +
+
+
+ ); +} \ No newline at end of file diff --git a/app/links/[id]/page.tsx b/app/(app)/links/[id]/page.tsx similarity index 100% rename from app/links/[id]/page.tsx rename to app/(app)/links/[id]/page.tsx diff --git a/app/links/page.tsx b/app/(app)/links/page.tsx similarity index 100% rename from app/links/page.tsx rename to app/(app)/links/page.tsx diff --git a/app/(app)/page.tsx b/app/(app)/page.tsx new file mode 100644 index 0000000..f762589 --- /dev/null +++ b/app/(app)/page.tsx @@ -0,0 +1,59 @@ +import Link from 'next/link'; + +export default function Home() { + return ( +
+
+

+ Welcome to ShortURL Analytics +

+
+ +

+ Dashboard +

+

+ View your overall analytics and key metrics +

+ + +

+ Events +

+

+ Track and analyze event data +

+ + +

+ Geographic Analysis +

+

+ Explore visitor locations and geographic patterns +

+ + +

+ Device Analytics +

+

+ Understand how users access your links +

+ +
+
+
+ ); +} \ No newline at end of file diff --git a/app/components/analytics/DeviceAnalytics.tsx b/app/components/analytics/DeviceAnalytics.tsx index 14b3194..290d905 100644 --- a/app/components/analytics/DeviceAnalytics.tsx +++ b/app/components/analytics/DeviceAnalytics.tsx @@ -1,6 +1,8 @@ "use client"; -import { DeviceAnalytics as DeviceAnalyticsType } from '../../api/types'; +import { useEffect, useRef } from 'react'; +import { DeviceAnalytics as DeviceAnalyticsType } from '@/app/api/types'; +import { Chart, PieController, ArcElement, Tooltip, Legend } from 'chart.js'; interface DeviceAnalyticsProps { data: DeviceAnalyticsType; diff --git a/app/components/analytics/GeoAnalytics.tsx b/app/components/analytics/GeoAnalytics.tsx index 41d737a..41dd942 100644 --- a/app/components/analytics/GeoAnalytics.tsx +++ b/app/components/analytics/GeoAnalytics.tsx @@ -1,6 +1,8 @@ "use client"; -import { GeoData } from '../../api/types'; +import { useEffect, useRef } from 'react'; +import { GeoData } from '@/app/api/types'; +import { Chart, PieController, ArcElement, Tooltip, Legend } from 'chart.js'; interface GeoAnalyticsProps { data: GeoData[]; diff --git a/app/components/charts/TimeSeriesChart.tsx b/app/components/charts/TimeSeriesChart.tsx index 3753c45..6215114 100644 --- a/app/components/charts/TimeSeriesChart.tsx +++ b/app/components/charts/TimeSeriesChart.tsx @@ -16,7 +16,7 @@ import { ChartOptions, TooltipItem } from 'chart.js'; -import { TimeSeriesData } from '../../api/types'; +import { TimeSeriesData } from '@/app/api/types'; // 注册 Chart.js 组件 ChartJS.register( diff --git a/app/layout.tsx b/app/layout.tsx index 317a463..83deb4c 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,68 +1,21 @@ import './globals.css'; import type { Metadata } from 'next'; -import { Inter } from 'next/font/google'; -import Link from 'next/link'; - -const inter = Inter({ subsets: ['latin'] }); export const metadata: Metadata = { - title: 'ShortURL Analytics', - description: 'Analytics dashboard for ShortURL service', + title: 'Link Management & Analytics', + description: 'Track and analyze shortened links', }; export default function RootLayout({ children, -}: { +}: Readonly<{ children: React.ReactNode; -}) { +}>) { return ( - - -
- -
- {children} -
-
+ + + {children} ); -} +} \ No newline at end of file diff --git a/app/layouts.tsx b/app/layouts.tsx deleted file mode 100644 index 83deb4c..0000000 --- a/app/layouts.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import './globals.css'; -import type { Metadata } from 'next'; - -export const metadata: Metadata = { - title: 'Link Management & Analytics', - description: 'Track and analyze shortened links', -}; - -export default function RootLayout({ - children, -}: Readonly<{ - children: React.ReactNode; -}>) { - return ( - - - {children} - - - ); -} \ No newline at end of file