From b308709edb303b7bd70cab01546c63a52fa411d0 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Fri, 6 Mar 2026 09:14:58 +0800 Subject: [PATCH] feat: Introduce a new Next.js modern frontend with a history API route and include legacy static assets. --- frontend/app/api/history/[name]/route.ts | 39 + frontend/app/modern/page.tsx | 5 + frontend/app/page.tsx | 12 +- frontend/public/legacy/index.html | 217 ++++ frontend/public/static/app.js | 1399 ++++++++++++++++++++++ frontend/public/static/style.css | 1289 ++++++++++++++++++++ 6 files changed, 2958 insertions(+), 3 deletions(-) create mode 100644 frontend/app/api/history/[name]/route.ts create mode 100644 frontend/app/modern/page.tsx create mode 100644 frontend/public/legacy/index.html create mode 100644 frontend/public/static/app.js create mode 100644 frontend/public/static/style.css diff --git a/frontend/app/api/history/[name]/route.ts b/frontend/app/api/history/[name]/route.ts new file mode 100644 index 00000000..76969c1d --- /dev/null +++ b/frontend/app/api/history/[name]/route.ts @@ -0,0 +1,39 @@ +import { NextResponse } from "next/server"; + +const API_BASE = process.env.POLYWEATHER_API_BASE_URL; + +export async function GET( + _req: Request, + context: { params: Promise<{ name: string }> }, +) { + if (!API_BASE) { + return NextResponse.json( + { error: "POLYWEATHER_API_BASE_URL is not configured" }, + { status: 500 }, + ); + } + + const { name } = await context.params; + const url = `${API_BASE}/api/history/${encodeURIComponent(name)}`; + + try { + const res = await fetch(url, { + headers: { Accept: "application/json" }, + cache: "no-store", + }); + if (!res.ok) { + const raw = await res.text(); + return NextResponse.json( + { error: `Backend returned ${res.status}`, detail: raw.slice(0, 300) }, + { status: 502 }, + ); + } + const data = await res.json(); + return NextResponse.json(data); + } catch (error) { + return NextResponse.json( + { error: "Failed to fetch history", detail: String(error) }, + { status: 500 }, + ); + } +} diff --git a/frontend/app/modern/page.tsx b/frontend/app/modern/page.tsx new file mode 100644 index 00000000..d4abf2bc --- /dev/null +++ b/frontend/app/modern/page.tsx @@ -0,0 +1,5 @@ +import { PolyWeatherDashboard } from "@/components/polyweather-dashboard"; + +export default function ModernPage() { + return ; +} diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx index e5af7622..19446599 100644 --- a/frontend/app/page.tsx +++ b/frontend/app/page.tsx @@ -1,5 +1,11 @@ -import { PolyWeatherDashboard } from "@/components/polyweather-dashboard"; - export default function HomePage() { - return ; + return ( +
+