Fix landing locale toggle cache path

This commit is contained in:
2569718930@qq.com
2026-06-14 05:11:37 +08:00
parent b4a23578f2
commit 0084235b57
5 changed files with 38 additions and 12 deletions
@@ -1,6 +1,7 @@
export type LandingLocale = "zh-CN" | "en-US";
export const LANDING_LOCALE_COOKIE = "polyweather.locale";
export const LANDING_LOCALE_QUERY_PARAM = "locale";
export const DEFAULT_LANDING_LOCALE: LandingLocale = "zh-CN";
export function normalizeLandingLocale(value: string | null | undefined): LandingLocale | null {
@@ -16,9 +17,13 @@ export function normalizeLandingLocale(value: string | null | undefined): Landin
}
export function pickLandingLocale(
queryLocale: string | null | undefined,
cookieLocale: string | null | undefined,
acceptLanguage: string | null | undefined,
): LandingLocale {
const fromQuery = normalizeLandingLocale(queryLocale);
if (fromQuery) return fromQuery;
const fromCookie = normalizeLandingLocale(cookieLocale);
if (fromCookie) return fromCookie;