From 1a577ec7998cb3cd9a91e67bfcf40abe0c52483c Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 21 Apr 2025 01:46:15 +0800 Subject: [PATCH] . --- components/sidebar/items/chat/chat-item.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/sidebar/items/chat/chat-item.tsx b/components/sidebar/items/chat/chat-item.tsx index 62c2d98..f2f8b0c 100644 --- a/components/sidebar/items/chat/chat-item.tsx +++ b/components/sidebar/items/chat/chat-item.tsx @@ -11,6 +11,7 @@ import { useParams, useRouter } from "next/navigation" import { FC, useContext, useRef } from "react" import { DeleteChat } from "./delete-chat" import { UpdateChat } from "./update-chat" +import { usePathname } from "next/navigation" interface ChatItemProps { chat: Tables<"chats"> @@ -25,6 +26,11 @@ export const ChatItem: FC = ({ chat }) => { availableOpenRouterModels } = useContext(ChatbotUIContext) + const pathname = usePathname() // 获取当前路径 + + // 提取当前路径中的 locale 部分 + const locale = pathname.split("/")[1] || "en" + const router = useRouter() const params = useParams() const isActive = params.chatid === chat.id || selectedChat?.id === chat.id @@ -33,7 +39,7 @@ export const ChatItem: FC = ({ chat }) => { const handleClick = () => { if (!selectedWorkspace) return - return router.push(`/${selectedWorkspace.id}/chat/${chat.id}`) + return router.push(`/{locale}/${selectedWorkspace.id}/chat/${chat.id}`) } const handleKeyDown = (e: React.KeyboardEvent) => {