From 52a445cff1251a3914fe34d06cde3dddd28de110 Mon Sep 17 00:00:00 2001 From: hailin Date: Sun, 18 May 2025 23:14:35 +0800 Subject: [PATCH] . --- chatdesk-ui/app/[locale]/layout.tsx | 39 ++--------------------------- chatdesk-ui/lib/ipconfig.ts | 7 ++++++ 2 files changed, 9 insertions(+), 37 deletions(-) create mode 100644 chatdesk-ui/lib/ipconfig.ts diff --git a/chatdesk-ui/app/[locale]/layout.tsx b/chatdesk-ui/app/[locale]/layout.tsx index affc886..54615f4 100644 --- a/chatdesk-ui/app/[locale]/layout.tsx +++ b/chatdesk-ui/app/[locale]/layout.tsx @@ -10,6 +10,7 @@ import { Inter } from "next/font/google" import { cookies } from "next/headers" import { ReactNode } from "react" import "./globals.css" +import { getRuntimeEnv } from "@/lib/ipconfig" // 新增引入 const inter = Inter({ subsets: ["latin"] }) const APP_NAME = "ChatAI UI" @@ -24,42 +25,6 @@ interface RootLayoutProps { } } -// export const metadata: Metadata = { -// applicationName: APP_NAME, -// title: { -// default: APP_DEFAULT_TITLE, -// template: APP_TITLE_TEMPLATE -// }, -// description: APP_DESCRIPTION, -// manifest: "/manifest.json", -// appleWebApp: { -// capable: true, -// statusBarStyle: "black", -// title: APP_DEFAULT_TITLE -// // startUpImage: [], -// }, -// formatDetection: { -// telephone: false -// }, -// openGraph: { -// type: "website", -// siteName: APP_NAME, -// title: { -// default: APP_DEFAULT_TITLE, -// template: APP_TITLE_TEMPLATE -// }, -// description: APP_DESCRIPTION -// }, -// twitter: { -// card: "summary", -// title: { -// default: APP_DEFAULT_TITLE, -// template: APP_TITLE_TEMPLATE -// }, -// description: APP_DESCRIPTION -// } -// } - export async function generateMetadata({ params: { locale } }: { @@ -127,7 +92,7 @@ export default async function RootLayout({ } const supabase = createServerClient( - process.env.NEXT_PUBLIC_SUPABASE_URL!, + getRuntimeEnv("SUPABASE_URL") ?? "http://localhost:8000", process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, { cookies: { diff --git a/chatdesk-ui/lib/ipconfig.ts b/chatdesk-ui/lib/ipconfig.ts new file mode 100644 index 0000000..7b550ba --- /dev/null +++ b/chatdesk-ui/lib/ipconfig.ts @@ -0,0 +1,7 @@ +// lib/ipconfig.ts +export function getRuntimeEnv(key: string): string | undefined { + if (typeof window !== "undefined" && typeof window.RUNTIME_ENV !== "undefined") { + return window.RUNTIME_ENV[key]; + } + return process.env[key]; +}