From a76497c110fd04c380a17a45296abebea92be63e Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 22 Apr 2025 19:08:41 +0800 Subject: [PATCH] . --- .../chat/chat-hooks/use-chat-handler.tsx | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/components/chat/chat-hooks/use-chat-handler.tsx b/components/chat/chat-hooks/use-chat-handler.tsx index a48eb9f..672d6e1 100644 --- a/components/chat/chat-hooks/use-chat-handler.tsx +++ b/components/chat/chat-hooks/use-chat-handler.tsx @@ -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 = () => {