This commit is contained in:
hailin 2025-04-22 19:08:41 +08:00
parent 5f099b3a60
commit a76497c110
1 changed files with 20 additions and 1 deletions

View File

@ -11,6 +11,9 @@ import { ChatMessage, ChatPayload, LLMID, ModelProvider } from "@/types"
import { useRouter } from "next/navigation"
import { useContext, useEffect, useRef } from "react"
import { LLM_LIST } from "../../../lib/models/llm/llm-list"
import i18nConfig from "@/i18nConfig"
import {
createTempMessages,
handleCreateChat,
@ -181,7 +184,23 @@ export const useChatHandler = () => {
// })
}
return router.push(`/${locale}/${selectedWorkspace.id}/chat`)
const pathSegments = pathname.split("/").filter(Boolean)
const locales = i18nConfig.locales
const defaultLocale = i18nConfig.defaultLocale
let locale: (typeof locales)[number] = defaultLocale
const segment = pathSegments[0] as (typeof locales)[number]
if (locales.includes(segment)) {
locale = segment
}
const homePath = locale === defaultLocale ? "/" : `/${locale}`
return router.push(`/${homePath}/${selectedWorkspace.id}/chat`)
// return router.push(`/${locale}/${selectedWorkspace.id}/chat`)
}
const handleFocusChatInput = () => {