From 50b2aeedccf115f4ac2fc907a9da42997e1159c3 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 21 Apr 2025 01:49:39 +0800 Subject: [PATCH] . --- components/sidebar/items/chat/chat-item.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/sidebar/items/chat/chat-item.tsx b/components/sidebar/items/chat/chat-item.tsx index f2f8b0c..6754915 100644 --- a/components/sidebar/items/chat/chat-item.tsx +++ b/components/sidebar/items/chat/chat-item.tsx @@ -26,10 +26,12 @@ export const ChatItem: FC = ({ chat }) => { availableOpenRouterModels } = useContext(ChatbotUIContext) - const pathname = usePathname() // 获取当前路径 - - // 提取当前路径中的 locale 部分 - const locale = pathname.split("/")[1] || "en" + const pathSegments = pathname.split("/").filter(Boolean) + const locales = i18nConfig.locales + const defaultLocale = i18nConfig.defaultLocale + + const pathLocale = locales.includes(pathSegments[0]) ? pathSegments[0] : null + const localePrefix = pathLocale && pathLocale !== defaultLocale ? `/${pathLocale}` : "" const router = useRouter() const params = useParams() @@ -39,7 +41,7 @@ export const ChatItem: FC = ({ chat }) => { const handleClick = () => { if (!selectedWorkspace) return - return router.push(`/{locale}/${selectedWorkspace.id}/chat/${chat.id}`) + return router.push(`/${localePrefix}/${selectedWorkspace.id}/chat/${chat.id}`) } const handleKeyDown = (e: React.KeyboardEvent) => {