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) => {