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 TranslationsProvider from "@/components/utility/translations-provider"
|
||||||
import initTranslations from "@/lib/i18n"
|
import initTranslations from "@/lib/i18n"
|
||||||
import { Database } from "@/supabase/types"
|
import { Database } from "@/supabase/types"
|
||||||
//import { createServerClient } from "@supabase/ssr"
|
|
||||||
import { getSupabaseServerClient } from "@/lib/supabase/server"
|
import { getSupabaseServerClient } from "@/lib/supabase/server"
|
||||||
import { Metadata, Viewport } from "next"
|
import { Metadata, Viewport } from "next"
|
||||||
import { Inter } from "next/font/google"
|
import { Inter } from "next/font/google"
|
||||||
|
|
@ -112,11 +111,7 @@ export default async function RootLayout({
|
||||||
// 遍历所有 cookies
|
// 遍历所有 cookies
|
||||||
for (const cookie of cookieStore.getAll()) {
|
for (const cookie of cookieStore.getAll()) {
|
||||||
console.log(`🍪 Cookie: ${cookie.name} = ${cookie.value}`);
|
console.log(`🍪 Cookie: ${cookie.name} = ${cookie.value}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const supabaseUrl = getRuntimeEnv("SUPABASE_URL");
|
|
||||||
// console.log("==========>Supabase URL: ", supabaseUrl);
|
|
||||||
|
|
||||||
|
|
||||||
let supabaseUrl = "";
|
let supabaseUrl = "";
|
||||||
try {
|
try {
|
||||||
|
|
@ -128,20 +123,7 @@ export default async function RootLayout({
|
||||||
return <div>Failed to fetch Supabase configuration, please try again later.</div>; // 出现错误时返回一个友好的提示
|
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 supabase = getSupabaseServerClient()
|
||||||
// const session = (await supabase.auth.getSession()).data.session
|
|
||||||
const { data, error } = await supabase.auth.getSession();
|
const { data, error } = await supabase.auth.getSession();
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log("[layout.tsx]............Session Error: ", error);
|
console.log("[layout.tsx]............Session Error: ", error);
|
||||||
|
|
@ -179,20 +161,4 @@ export default async function RootLayout({
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</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 { theme } = useTheme()
|
||||||
const { t, i18n } = useTranslation()
|
const { t, i18n } = useTranslation()
|
||||||
|
|
||||||
const [preferredLanguage, setPreferredLanguage] = useState<string>('en') // 默认语言为 'en'
|
const [preferredLanguage, setPreferredLanguage] = useState<string>('en')
|
||||||
|
|
||||||
// 根据 localStorage 或 cookie 设置 preferredLanguage
|
// 根据 localStorage 或 cookie 设置 preferredLanguage
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const languageFromStorage = localStorage.getItem('preferred-language') || document.cookie.split('; ').find(row => row.startsWith('preferred-language='))?.split('=')[1];
|
const languageFromStorage = localStorage.getItem('preferred-language') || document.cookie.split('; ').find(row => row.startsWith('preferred-language='))?.split('=')[1];
|
||||||
if (languageFromStorage) {
|
if (languageFromStorage) {
|
||||||
setPreferredLanguage(languageFromStorage);
|
setPreferredLanguage(languageFromStorage);
|
||||||
// 更新 i18n 的语言设置
|
|
||||||
//i18n.changeLanguage(languageFromStorage); // 通过 i18n 更新默认语言
|
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -181,12 +181,8 @@ export const GlobalState: FC<GlobalStateProps> = ({ children }) => {
|
||||||
setProfile(profile)
|
setProfile(profile)
|
||||||
|
|
||||||
if (profile !== null && profile !== undefined && !profile.has_onboarded) {
|
if (profile !== null && profile !== undefined && !profile.has_onboarded) {
|
||||||
// 修正 homePath 拼接逻辑,避免 //setup 问题
|
|
||||||
const homePath = locale === defaultLocale ? "" : `/${locale}`
|
const homePath = locale === defaultLocale ? "" : `/${locale}`
|
||||||
//const targetPath = `${homePath}/setup`
|
|
||||||
const targetPath = `${homePath}/setup`.replace(/\/\//g, '/')
|
const targetPath = `${homePath}/setup`.replace(/\/\//g, '/')
|
||||||
|
|
||||||
|
|
||||||
router.push(targetPath)
|
router.push(targetPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,12 +54,23 @@ export const fetchHostedModels = async (profile: Tables<"profiles">) => {
|
||||||
|
|
||||||
export const fetchOllamaModels = async () => {
|
export const fetchOllamaModels = async () => {
|
||||||
try {
|
try {
|
||||||
|
// const response = await fetch(
|
||||||
|
// process.env.NEXT_PUBLIC_OLLAMA_URL + "/api/tags"
|
||||||
|
// )
|
||||||
|
|
||||||
const response = await fetch(
|
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) {
|
if (!response.ok) {
|
||||||
throw new Error(`Ollama server is not responding.`)
|
throw new Error(`LLM server is not responding.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue