This commit is contained in:
hailin 2025-04-21 01:49:39 +08:00
parent 1a577ec799
commit 50b2aeedcc
1 changed files with 7 additions and 5 deletions

View File

@ -26,10 +26,12 @@ export const ChatItem: FC<ChatItemProps> = ({ 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<ChatItemProps> = ({ 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<HTMLDivElement>) => {