From 6a47033ab27537edcda2b4c1f95eea370c2cc6b6 Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 27 May 2025 12:28:06 +0800 Subject: [PATCH] . --- chatdesk-ui/app/[locale]/layout.tsx | 36 +------------------ chatdesk-ui/app/[locale]/page.tsx | 6 ++-- .../components/utility/global-state.tsx | 4 --- chatdesk-ui/lib/models/fetch-models.ts | 17 +++++++-- 4 files changed, 17 insertions(+), 46 deletions(-) diff --git a/chatdesk-ui/app/[locale]/layout.tsx b/chatdesk-ui/app/[locale]/layout.tsx index 7517314..3ec1c8f 100644 --- a/chatdesk-ui/app/[locale]/layout.tsx +++ b/chatdesk-ui/app/[locale]/layout.tsx @@ -4,7 +4,6 @@ import { Providers } from "@/components/utility/providers" import TranslationsProvider from "@/components/utility/translations-provider" import initTranslations from "@/lib/i18n" import { Database } from "@/supabase/types" -//import { createServerClient } from "@supabase/ssr" import { getSupabaseServerClient } from "@/lib/supabase/server" import { Metadata, Viewport } from "next" import { Inter } from "next/font/google" @@ -112,11 +111,7 @@ export default async function RootLayout({ // 遍历所有 cookies for (const cookie of cookieStore.getAll()) { console.log(`🍪 Cookie: ${cookie.name} = ${cookie.value}`); - } - - // const supabaseUrl = getRuntimeEnv("SUPABASE_URL"); - // console.log("==========>Supabase URL: ", supabaseUrl); - + } let supabaseUrl = ""; try { @@ -128,20 +123,7 @@ export default async function RootLayout({ return
Failed to fetch Supabase configuration, please try again later.
; // 出现错误时返回一个友好的提示 } - // const supabase = createServerClient( - // getRuntimeEnv("SUPABASE_URL") ?? "http://localhost:8000", - // process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!, - // { - // cookies: { - // get(name: string) { - // return cookieStore.get(name)?.value - // } - // } - // } - // ) - const supabase = getSupabaseServerClient() - // const session = (await supabase.auth.getSession()).data.session const { data, error } = await supabase.auth.getSession(); if (error) { console.log("[layout.tsx]............Session Error: ", error); @@ -179,20 +161,4 @@ export default async function RootLayout({ ) - - // return ( - // - // - // - //
- // {data.session ? {children} : children} - //
- //
- //
- // ) - } diff --git a/chatdesk-ui/app/[locale]/page.tsx b/chatdesk-ui/app/[locale]/page.tsx index feafef9..74ed0ca 100644 --- a/chatdesk-ui/app/[locale]/page.tsx +++ b/chatdesk-ui/app/[locale]/page.tsx @@ -15,15 +15,13 @@ export default function HomePage() { const { theme } = useTheme() const { t, i18n } = useTranslation() - const [preferredLanguage, setPreferredLanguage] = useState('en') // 默认语言为 'en' + const [preferredLanguage, setPreferredLanguage] = useState('en') // 根据 localStorage 或 cookie 设置 preferredLanguage useEffect(() => { const languageFromStorage = localStorage.getItem('preferred-language') || document.cookie.split('; ').find(row => row.startsWith('preferred-language='))?.split('=')[1]; if (languageFromStorage) { - setPreferredLanguage(languageFromStorage); - // 更新 i18n 的语言设置 - //i18n.changeLanguage(languageFromStorage); // 通过 i18n 更新默认语言 + setPreferredLanguage(languageFromStorage); } }, []); diff --git a/chatdesk-ui/components/utility/global-state.tsx b/chatdesk-ui/components/utility/global-state.tsx index acd4994..46501d9 100644 --- a/chatdesk-ui/components/utility/global-state.tsx +++ b/chatdesk-ui/components/utility/global-state.tsx @@ -181,12 +181,8 @@ export const GlobalState: FC = ({ children }) => { setProfile(profile) if (profile !== null && profile !== undefined && !profile.has_onboarded) { - // 修正 homePath 拼接逻辑,避免 //setup 问题 const homePath = locale === defaultLocale ? "" : `/${locale}` - //const targetPath = `${homePath}/setup` const targetPath = `${homePath}/setup`.replace(/\/\//g, '/') - - router.push(targetPath) } diff --git a/chatdesk-ui/lib/models/fetch-models.ts b/chatdesk-ui/lib/models/fetch-models.ts index 0f34709..f08791e 100644 --- a/chatdesk-ui/lib/models/fetch-models.ts +++ b/chatdesk-ui/lib/models/fetch-models.ts @@ -54,12 +54,23 @@ export const fetchHostedModels = async (profile: Tables<"profiles">) => { export const fetchOllamaModels = async () => { try { + // const response = await fetch( + // process.env.NEXT_PUBLIC_OLLAMA_URL + "/api/tags" + // ) + const response = await fetch( - process.env.NEXT_PUBLIC_OLLAMA_URL + "/api/tags" - ) + process.env.NEXT_PUBLIC_OLLAMA_URL + "/api/tags", + { + method: "GET", + headers: { + "Authorization": "Bearer token-abc123", + "Content-Type": "application/json" + } + } + ) if (!response.ok) { - throw new Error(`Ollama server is not responding.`) + throw new Error(`LLM server is not responding.`) } const data = await response.json()