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`) }