This commit is contained in:
hailin 2025-05-27 16:20:50 +08:00
parent c62109c022
commit ed7afaafb6
1 changed files with 20 additions and 9 deletions

View File

@ -26,6 +26,7 @@ import { useTranslation } from 'react-i18next'
import { usePathname } from "next/navigation" import { usePathname } from "next/navigation"
import i18nConfig from "@/i18nConfig" import i18nConfig from "@/i18nConfig"
import { createModel } from "@/db/models"
export default function SetupPage() { export default function SetupPage() {
const { const {
@ -94,9 +95,7 @@ export default function SetupPage() {
if (!session) { if (!session) {
// 强制跳转到带有 locale 的 login 页面 // 强制跳转到带有 locale 的 login 页面
console.log("...........[setup/page.tsx]") console.log("...........[setup/page.tsx]")
//return router.push(`${homePath}/login`)
return router.push(getLocalizedPath("login")) return router.push(getLocalizedPath("login"))
// return router.push(`/${locale}/login`)
} else { } else {
const user = session.user const user = session.user
@ -123,8 +122,6 @@ export default function SetupPage() {
const homeWorkspaceId = await getHomeWorkspaceByUserId( const homeWorkspaceId = await getHomeWorkspaceByUserId(
session.user.id session.user.id
) )
//return router.push(`${homePath}/${homeWorkspaceId}/chat`)
// return router.push(`/${locale}/${homeWorkspaceId}/chat`)
return router.push(getLocalizedPath(`${homeWorkspaceId}/chat`)) return router.push(getLocalizedPath(`${homeWorkspaceId}/chat`))
} }
} }
@ -144,11 +141,8 @@ export default function SetupPage() {
} }
const handleSaveSetupSetting = async () => { const handleSaveSetupSetting = async () => {
//const supabaseClient = await supabase(); // Await the client creation
const session = (await supabase.auth.getSession()).data.session const session = (await supabase.auth.getSession()).data.session
if (!session) { if (!session) {
// return router.push(`/${locale}/login`)
//return (`${homePath}/login`)
return router.push(getLocalizedPath("login")) return router.push(getLocalizedPath("login"))
} }
@ -184,12 +178,29 @@ export default function SetupPage() {
const homeWorkspace = workspaces.find(w => w.is_home) const homeWorkspace = workspaces.find(w => w.is_home)
const baseUrl = typeof window !== "undefined"
? `http://${window.location.hostname}:30000/v1`
: "http://localhost:30000/v1"
if (typeof window !== "undefined") {
await createModel(
{
user_id: profile.user_id,
name: "OpenAI API-compatible model",
model_id: "AI",
base_url: baseUrl,
api_key: "token-abc123",
description: "Default LLM model created during onboarding",
context_length: 131072
},
homeWorkspace.id
)
}
// There will always be a home workspace // There will always be a home workspace
setSelectedWorkspace(homeWorkspace!) setSelectedWorkspace(homeWorkspace!)
setWorkspaces(workspaces) setWorkspaces(workspaces)
// return router.push(`${homePath}/${homeWorkspace?.id}/chat`)
// return router.push(`/${locale}/${homeWorkspace?.id}/chat`)
return router.push(getLocalizedPath(`${homeWorkspace?.id}/chat`)) return router.push(getLocalizedPath(`${homeWorkspace?.id}/chat`))
} }