This commit is contained in:
parent
7fcd5a3f41
commit
6a47033ab2
|
|
@ -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 <div>Failed to fetch Supabase configuration, please try again later.</div>; // 出现错误时返回一个友好的提示
|
||||
}
|
||||
|
||||
// const supabase = createServerClient<Database>(
|
||||
// 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({
|
|||
</body>
|
||||
</html>
|
||||
)
|
||||
|
||||
// return (
|
||||
// <Providers attribute="class" defaultTheme="dark">
|
||||
// <TranslationsProvider
|
||||
// namespaces={i18nNamespaces}
|
||||
// locale={locale}
|
||||
// resources={resources}
|
||||
// >
|
||||
// <Toaster richColors position="top-center" duration={3000} />
|
||||
// <div className={`${inter.className} bg-background text-foreground flex h-dvh flex-col items-center overflow-x-auto`}>
|
||||
// {data.session ? <GlobalState>{children}</GlobalState> : children}
|
||||
// </div>
|
||||
// </TranslationsProvider>
|
||||
// </Providers>
|
||||
// )
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,15 +15,13 @@ export default function HomePage() {
|
|||
const { theme } = useTheme()
|
||||
const { t, i18n } = useTranslation()
|
||||
|
||||
const [preferredLanguage, setPreferredLanguage] = useState<string>('en') // 默认语言为 'en'
|
||||
const [preferredLanguage, setPreferredLanguage] = useState<string>('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);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
|
|
|||
|
|
@ -181,12 +181,8 @@ export const GlobalState: FC<GlobalStateProps> = ({ 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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in New Issue