diff --git a/src/renderer/src/components/Popups/PromptPopup.tsx b/src/renderer/src/components/Popups/PromptPopup.tsx index 9d8b9ae752..0d254d3fb9 100644 --- a/src/renderer/src/components/Popups/PromptPopup.tsx +++ b/src/renderer/src/components/Popups/PromptPopup.tsx @@ -1,6 +1,6 @@ import { Input, Modal } from 'antd' import { TextAreaProps } from 'antd/es/input' -import { useRef, useState } from 'react' +import { ReactNode, useRef, useState } from 'react' import { Box } from '../Layout' import { TopView } from '../TopView' @@ -11,6 +11,7 @@ interface PromptPopupShowParams { defaultValue?: string inputPlaceholder?: string inputProps?: TextAreaProps + extraNode?: ReactNode } interface Props extends PromptPopupShowParams { @@ -23,6 +24,7 @@ const PromptPopupContainer: React.FC = ({ defaultValue = '', inputPlaceholder = '', inputProps = {}, + extraNode = null, resolve }) => { const [value, setValue] = useState(defaultValue) @@ -88,6 +90,7 @@ const PromptPopupContainer: React.FC = ({ rows={1} {...inputProps} /> + {extraNode} ) } diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index 1841716293..8f05b3d2d9 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -584,7 +584,8 @@ }, "edit": { "placeholder": "Enter new name", - "title": "Edit Name" + "title": "Edit Name", + "title_tip": "Tips: Double-click the topic name to rename it directly in place" }, "export": { "image": "Export as image", diff --git a/src/renderer/src/i18n/locales/ja-jp.json b/src/renderer/src/i18n/locales/ja-jp.json index 5842f6b24b..9f5f782ea7 100644 --- a/src/renderer/src/i18n/locales/ja-jp.json +++ b/src/renderer/src/i18n/locales/ja-jp.json @@ -584,7 +584,8 @@ }, "edit": { "placeholder": "新しい名前を入力", - "title": "名前を編集" + "title": "名前を編集", + "title_tip": "ヒント: トピック名をダブルクリックすると、直接その場で名前を変更できます" }, "export": { "image": "画像としてエクスポート", diff --git a/src/renderer/src/i18n/locales/ru-ru.json b/src/renderer/src/i18n/locales/ru-ru.json index d1a8fff8e5..4896b85fee 100644 --- a/src/renderer/src/i18n/locales/ru-ru.json +++ b/src/renderer/src/i18n/locales/ru-ru.json @@ -584,7 +584,8 @@ }, "edit": { "placeholder": "Введите новый заголовок", - "title": "Редактировать заголовок" + "title": "Редактировать заголовок", + "title_tip": "Совет: двойной щелчок по названию темы позволяет переименовать её на месте" }, "export": { "image": "Экспорт как изображение", diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index 812d182c94..87f50debf0 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -584,7 +584,8 @@ }, "edit": { "placeholder": "输入新名称", - "title": "编辑话题名" + "title": "编辑话题名", + "title_tip": "提示: 双击话题名可以直接就地重命名" }, "export": { "image": "导出为图片", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index 5b0bc186ca..f92c27f973 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -584,7 +584,8 @@ }, "edit": { "placeholder": "輸入新名稱", - "title": "編輯名稱" + "title": "編輯名稱", + "title_tip": "提示:雙擊話題名可以直接就地重新命名" }, "export": { "image": "匯出為圖片", diff --git a/src/renderer/src/i18n/translate/el-gr.json b/src/renderer/src/i18n/translate/el-gr.json index 05c1efa2cf..9cbbda52c1 100644 --- a/src/renderer/src/i18n/translate/el-gr.json +++ b/src/renderer/src/i18n/translate/el-gr.json @@ -584,7 +584,8 @@ }, "edit": { "placeholder": "Εισαγάγετε το νέο όνομα", - "title": "Επεξεργασία ονόματος θέματος" + "title": "Επεξεργασία ονόματος θέματος", + "title_tip": "Συμβουλές: Διπλό κλικ στο όνομα του θέματος για να το μετονομάσετε απευθείας" }, "export": { "image": "Εξαγωγή ως εικόνα", diff --git a/src/renderer/src/i18n/translate/es-es.json b/src/renderer/src/i18n/translate/es-es.json index d63cda4c58..25e186c567 100644 --- a/src/renderer/src/i18n/translate/es-es.json +++ b/src/renderer/src/i18n/translate/es-es.json @@ -584,7 +584,8 @@ }, "edit": { "placeholder": "Introduce nuevo nombre", - "title": "Editar nombre del tema" + "title": "Editar nombre del tema", + "title_tip": "Consejos: hacer doble clic en el nombre del tema permite cambiar el nombre directamente en el lugar" }, "export": { "image": "Exportar como imagen", diff --git a/src/renderer/src/i18n/translate/fr-fr.json b/src/renderer/src/i18n/translate/fr-fr.json index a7575df024..266985c94b 100644 --- a/src/renderer/src/i18n/translate/fr-fr.json +++ b/src/renderer/src/i18n/translate/fr-fr.json @@ -584,7 +584,8 @@ }, "edit": { "placeholder": "Entrez un nouveau nom", - "title": "Modifier le nom du sujet" + "title": "Modifier le nom du sujet", + "title_tip": "Conseil : double-cliquez sur le nom du sujet pour le renommer directement sur place" }, "export": { "image": "Exporter sous forme d'image", diff --git a/src/renderer/src/i18n/translate/pt-pt.json b/src/renderer/src/i18n/translate/pt-pt.json index 3234ad8215..def1ee8900 100644 --- a/src/renderer/src/i18n/translate/pt-pt.json +++ b/src/renderer/src/i18n/translate/pt-pt.json @@ -584,7 +584,8 @@ }, "edit": { "placeholder": "Digite novo nome", - "title": "Editar nome do tópico" + "title": "Editar nome do tópico", + "title_tip": "Dicas: Clique duas vezes no nome do tópico para renomeá-lo diretamente no local" }, "export": { "image": "Exportar como imagem", diff --git a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx index 52d442b5ae..e5e31b6d63 100644 --- a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx @@ -222,9 +222,19 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic, key: 'rename', icon: , disabled: isRenaming(topic.id), - onClick() { - setEditingTopicId(topic.id) - topicEdit.startEdit(topic.name) + async onClick() { + const name = await PromptPopup.show({ + title: t('chat.topics.edit.title'), + message: '', + defaultValue: topic?.name || '', + extraNode: ( +
{t('chat.topics.edit.title_tip')}
+ ) + }) + if (name && topic?.name !== name) { + const updatedTopic = { ...topic, name, isNameManuallyEdited: true } + updateTopic(updatedTopic) + } } }, { @@ -448,7 +458,6 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic, assistants, assistant, updateTopic, - topicEdit, activeTopic.id, setActiveTopic, onPinTopic, @@ -519,7 +528,13 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic, onClick={(e) => e.stopPropagation()} /> ) : ( - + { + setEditingTopicId(topic.id) + topicEdit.startEdit(topic.name) + }}> {topicName} )} @@ -622,6 +637,7 @@ const TopicNameContainer = styled.div` flex-direction: row; align-items: center; gap: 4px; + height: 20px; justify-content: space-between; ` @@ -675,19 +691,14 @@ const TopicName = styled.div` const TopicEditInput = styled.input` background: var(--color-background); - border: 1px solid var(--color-border); - border-radius: 4px; + border: none; color: var(--color-text-1); font-size: 13px; font-family: inherit; padding: 2px 6px; width: 100%; outline: none; - - &:focus { - border-color: var(--color-primary); - box-shadow: 0 0 0 2px var(--color-primary-alpha); - } + padding: 0; ` const PendingIndicator = styled.div.attrs({