This commit is contained in:
parent
e29dc948c7
commit
1a577ec799
|
|
@ -11,6 +11,7 @@ import { useParams, useRouter } from "next/navigation"
|
||||||
import { FC, useContext, useRef } from "react"
|
import { FC, useContext, useRef } from "react"
|
||||||
import { DeleteChat } from "./delete-chat"
|
import { DeleteChat } from "./delete-chat"
|
||||||
import { UpdateChat } from "./update-chat"
|
import { UpdateChat } from "./update-chat"
|
||||||
|
import { usePathname } from "next/navigation"
|
||||||
|
|
||||||
interface ChatItemProps {
|
interface ChatItemProps {
|
||||||
chat: Tables<"chats">
|
chat: Tables<"chats">
|
||||||
|
|
@ -25,6 +26,11 @@ export const ChatItem: FC<ChatItemProps> = ({ chat }) => {
|
||||||
availableOpenRouterModels
|
availableOpenRouterModels
|
||||||
} = useContext(ChatbotUIContext)
|
} = useContext(ChatbotUIContext)
|
||||||
|
|
||||||
|
const pathname = usePathname() // 获取当前路径
|
||||||
|
|
||||||
|
// 提取当前路径中的 locale 部分
|
||||||
|
const locale = pathname.split("/")[1] || "en"
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const params = useParams()
|
const params = useParams()
|
||||||
const isActive = params.chatid === chat.id || selectedChat?.id === chat.id
|
const isActive = params.chatid === chat.id || selectedChat?.id === chat.id
|
||||||
|
|
@ -33,7 +39,7 @@ export const ChatItem: FC<ChatItemProps> = ({ chat }) => {
|
||||||
|
|
||||||
const handleClick = () => {
|
const handleClick = () => {
|
||||||
if (!selectedWorkspace) return
|
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>) => {
|
const handleKeyDown = (e: React.KeyboardEvent<HTMLDivElement>) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue