新增用户意图确认功能

This commit is contained in:
likun committed 2026-05-13 14:36:44 +08:00
1 parent cf2e4bdd9c
commit b8926f00d7
574 files changed
+97664 -97208

No files matched your search

+41 -41
View File
@@ -1,41 +1,41 @@
/**
* Cookie utilities for locale management
* Works on both client and server side
*/
const LOCALE_COOKIE_NAME = "locale";
/**
* Get locale from cookie (client-side)
*/
export function getLocaleFromCookie(): string | null {
if (typeof document === "undefined") {
return null;
}
const cookies = document.cookie.split(";");
for (const cookie of cookies) {
const [name, value] = cookie.trim().split("=");
if (name === LOCALE_COOKIE_NAME) {
return decodeURIComponent(value ?? "");
}
}
return null;
}
/**
* Set locale in cookie (client-side)
*/
export function setLocaleInCookie(locale: string): void {
if (typeof document === "undefined") {
return;
}
// Set cookie with 1 year expiration
const maxAge = 365 * 24 * 60 * 60; // 1 year in seconds
document.cookie = `${LOCALE_COOKIE_NAME}=${encodeURIComponent(locale)}; max-age=${maxAge}; path=/; SameSite=Lax`;
}
export async function getLocaleFromCookieServer(): Promise<string | null> {
return getLocaleFromCookie();
}
/**
* Cookie utilities for locale management
* Works on both client and server side
*/
const LOCALE_COOKIE_NAME = "locale";
/**
* Get locale from cookie (client-side)
*/
export function getLocaleFromCookie(): string | null {
if (typeof document === "undefined") {
return null;
}
const cookies = document.cookie.split(";");
for (const cookie of cookies) {
const [name, value] = cookie.trim().split("=");
if (name === LOCALE_COOKIE_NAME) {
return decodeURIComponent(value ?? "");
}
}
return null;
}
/**
* Set locale in cookie (client-side)
*/
export function setLocaleInCookie(locale: string): void {
if (typeof document === "undefined") {
return;
}
// Set cookie with 1 year expiration
const maxAge = 365 * 24 * 60 * 60; // 1 year in seconds
document.cookie = `${LOCALE_COOKIE_NAME}=${encodeURIComponent(locale)}; max-age=${maxAge}; path=/; SameSite=Lax`;
}
export async function getLocaleFromCookieServer(): Promise<string | null> {
return getLocaleFromCookie();
}