From 38e095d61bf5def11ccb3b1a10f1ec9cc4cc6297 Mon Sep 17 00:00:00 2001 From: hailin Date: Tue, 22 Apr 2025 20:05:44 +0800 Subject: [PATCH] . --- components/chat/chat-hooks/use-chat-handler.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/components/chat/chat-hooks/use-chat-handler.tsx b/components/chat/chat-hooks/use-chat-handler.tsx index 04db3fa..bc2fb7e 100644 --- a/components/chat/chat-hooks/use-chat-handler.tsx +++ b/components/chat/chat-hooks/use-chat-handler.tsx @@ -188,18 +188,21 @@ export const useChatHandler = () => { 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}` + + // ✅ 正确构造 localePrefix,不包含前导 / + const localePrefix = locale === defaultLocale ? "" : `/${locale}` + + console.log("[use-chat-handler.tsx]...........localePrefix", localePrefix) - console.log("[use-chat-handler.tsx]...........homePath",homePath) - return router.push(`/${homePath}/${selectedWorkspace.id}/chat`) + console.log("[use-chat-handler.tsx]...........homePath",localePrefix) + return router.push(`${localePrefix}/${selectedWorkspace.id}/chat`) // return router.push(`/${locale}/${selectedWorkspace.id}/chat`) }