From 0084235b571a3ca3d46101d09b5652315d495a4d Mon Sep 17 00:00:00 2001
From: "2569718930@qq.com" <2569718930@qq.com>
Date: Sun, 14 Jun 2026 05:11:37 +0800
Subject: [PATCH] Fix landing locale toggle cache path
---
frontend/app/page.tsx | 5 ++++-
.../landing/InstitutionalLandingPage.tsx | 11 ++++++++---
.../components/landing/LandingLocaleToggle.tsx | 13 +++++--------
.../__tests__/landingPricingReferral.test.ts | 16 ++++++++++++++++
frontend/components/landing/landingLocale.ts | 5 +++++
5 files changed, 38 insertions(+), 12 deletions(-)
diff --git a/frontend/app/page.tsx b/frontend/app/page.tsx
index 6331f530..770662e7 100644
--- a/frontend/app/page.tsx
+++ b/frontend/app/page.tsx
@@ -1,6 +1,7 @@
import type { Metadata } from "next";
import { redirect } from "next/navigation";
import { InstitutionalLandingPage } from "@/components/landing/InstitutionalLandingPage";
+import { LANDING_LOCALE_QUERY_PARAM } from "@/components/landing/landingLocale";
export const metadata: Metadata = {
title: "PolyWeather | Institutional Weather Signal Intelligence",
@@ -32,6 +33,8 @@ export default async function HomePage({
const qs = usp.toString();
redirect(`/auth/callback${qs ? `?${qs}` : ""}`);
}
+ const rawLandingLocale = params[LANDING_LOCALE_QUERY_PARAM];
+ const landingLocale = Array.isArray(rawLandingLocale) ? rawLandingLocale[0] : rawLandingLocale;
const jsonLd = {
"@context": "https://schema.org",
"@type": "WebApplication",
@@ -68,7 +71,7 @@ export default async function HomePage({
type="application/ld+json"
dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
/>
-
+
>
);
}
diff --git a/frontend/components/landing/InstitutionalLandingPage.tsx b/frontend/components/landing/InstitutionalLandingPage.tsx
index eb2431b1..25c08d8a 100644
--- a/frontend/components/landing/InstitutionalLandingPage.tsx
+++ b/frontend/components/landing/InstitutionalLandingPage.tsx
@@ -227,9 +227,10 @@ function WeatherWorkflowIllustration() {
);
}
-async function resolveLandingLocale(): Promise {
+async function resolveLandingLocale(queryLocale?: string | null): Promise {
const [cookieStore, headerStore] = await Promise.all([cookies(), headers()]);
return pickLandingLocale(
+ queryLocale,
cookieStore.get(LANDING_LOCALE_COOKIE)?.value,
headerStore.get("accept-language"),
);
@@ -829,7 +830,11 @@ function InstitutionalLandingScreen({ locale }: { locale: LandingLocale }) {
);
}
-export async function InstitutionalLandingPage() {
- const locale = await resolveLandingLocale();
+export async function InstitutionalLandingPage({
+ queryLocale,
+}: {
+ queryLocale?: string | null;
+} = {}) {
+ const locale = await resolveLandingLocale(queryLocale);
return ;
}
diff --git a/frontend/components/landing/LandingLocaleToggle.tsx b/frontend/components/landing/LandingLocaleToggle.tsx
index 154edfc9..201223d3 100644
--- a/frontend/components/landing/LandingLocaleToggle.tsx
+++ b/frontend/components/landing/LandingLocaleToggle.tsx
@@ -1,9 +1,8 @@
"use client";
-import { useTransition } from "react";
-import { useRouter } from "next/navigation";
import {
LANDING_LOCALE_COOKIE,
+ LANDING_LOCALE_QUERY_PARAM,
nextLandingLocale,
type LandingLocale,
} from "@/components/landing/landingLocale";
@@ -11,8 +10,6 @@ import {
const ONE_YEAR_SECONDS = 60 * 60 * 24 * 365;
export function LandingLocaleToggle({ locale }: { locale: LandingLocale }) {
- const router = useRouter();
- const [isPending, startTransition] = useTransition();
const isEn = locale === "en-US";
const toggleLocale = () => {
@@ -24,16 +21,16 @@ export function LandingLocaleToggle({ locale }: { locale: LandingLocale }) {
} catch {
// Locale persistence is best-effort; the cookie is enough for SSR.
}
- startTransition(() => {
- router.refresh();
- });
+
+ const url = new URL(window.location.href);
+ url.searchParams.set(LANDING_LOCALE_QUERY_PARAM, nextLocale);
+ window.location.assign(url.toString());
};
return (