From 06d18e890103ec65fa7791d5948004d6adf4f128 Mon Sep 17 00:00:00 2001 From: hailin Date: Mon, 21 Apr 2025 00:03:32 +0800 Subject: [PATCH] . --- components/sidebar/items/all/sidebar-display-item.tsx | 10 +++++++++- components/sidebar/sidebar-switch-item.tsx | 3 ++- components/ui/dashboard.tsx | 7 ++++++- public/locales/en/translation.json | 3 ++- public/locales/ja/translation.json | 3 ++- public/locales/zh/translation.json | 3 ++- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/components/sidebar/items/all/sidebar-display-item.tsx b/components/sidebar/items/all/sidebar-display-item.tsx index d8f0864..c03bca9 100644 --- a/components/sidebar/items/all/sidebar-display-item.tsx +++ b/components/sidebar/items/all/sidebar-display-item.tsx @@ -7,6 +7,9 @@ import { useRouter } from "next/navigation" import { FC, useContext, useRef, useState } from "react" import { SidebarUpdateItem } from "./sidebar-update-item" +import { usePathname } from "next/navigation" + + interface SidebarItemProps { item: DataItemType isTyping: boolean @@ -27,6 +30,11 @@ export const SidebarItem: FC = ({ const { selectedWorkspace, setChats, setSelectedAssistant } = useContext(ChatbotUIContext) + const pathname = usePathname() // 获取当前路径 + + // 提取当前路径中的 locale 部分 + const locale = pathname.split("/")[1] || "en" + const router = useRouter() const itemRef = useRef(null) @@ -60,7 +68,7 @@ export const SidebarItem: FC = ({ setChats(prevState => [createdChat, ...prevState]) setSelectedAssistant(assistant) - return router.push(`/${selectedWorkspace.id}/chat/${createdChat.id}`) + return router.push(`/${locale}/${selectedWorkspace.id}/chat/${createdChat.id}`) }, tools: async (item: any) => {}, models: async (item: any) => {} diff --git a/components/sidebar/sidebar-switch-item.tsx b/components/sidebar/sidebar-switch-item.tsx index 2ccc92f..d3e2a5e 100644 --- a/components/sidebar/sidebar-switch-item.tsx +++ b/components/sidebar/sidebar-switch-item.tsx @@ -17,7 +17,8 @@ export const SidebarSwitchItem: FC = ({ return ( {contentType[0].toUpperCase() + contentType.substring(1)} + //
{contentType[0].toUpperCase() + contentType.substring(1)}
+ {
{t(`contentType.${contentType}`)}
} } trigger={ = ({ children }) => { + + const { t } = useTranslation() + useHotkey("s", () => setShowSidebar(prevState => !prevState)) const pathname = usePathname() @@ -107,7 +112,7 @@ export const Dashboard: FC = ({ children }) => { > {isDragging ? (
- drop file here + {t("side.dropFileHere")}
) : ( children diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index cd9d1ee..f4e232b 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -202,7 +202,8 @@ "toolNamePlaceholder": "Tool name...", "toolDescriptionPlaceholder": "Tool description...", "customHeadersLabel": "Custom Headers", - "schemaLabel": "Schema" + "schemaLabel": "Schema", + "dropFileHere": "Drop file here" }, "contentType": { diff --git a/public/locales/ja/translation.json b/public/locales/ja/translation.json index cbf969f..a7fa44e 100644 --- a/public/locales/ja/translation.json +++ b/public/locales/ja/translation.json @@ -201,7 +201,8 @@ "toolNamePlaceholder": "ツール名...", "toolDescriptionPlaceholder": "ツールの説明...", "customHeadersLabel": "カスタムヘッダー", - "schemaLabel": "スキーマ" + "schemaLabel": "スキーマ", + "dropFileHere": "ここにファイルをドロップ" }, "contentType": { diff --git a/public/locales/zh/translation.json b/public/locales/zh/translation.json index b15781e..49fa5cd 100644 --- a/public/locales/zh/translation.json +++ b/public/locales/zh/translation.json @@ -201,7 +201,8 @@ "toolNamePlaceholder": "工具名称...", "toolDescriptionPlaceholder": "工具描述...", "customHeadersLabel": "自定义请求头", - "schemaLabel": "Schema" + "schemaLabel": "Schema", + "dropFileHere": "将文件拖放到此处" }, "contentType": {