This commit is contained in:
hailin 2025-04-21 01:46:15 +08:00
parent e29dc948c7
commit 1a577ec799
1 changed files with 7 additions and 1 deletions

View File

@ -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<ChatItemProps> = ({ 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<ChatItemProps> = ({ 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<HTMLDivElement>) => {