mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 06:19:05 +08:00
feat(TopicsTab): double click topic name to edit (#9382)
* feat(TopicsTab): 添加双击话题名称开始编辑功能 * feat(话题标签): 添加通过弹窗重命名话题的功能 * refactor(TopicsTab): 移除未使用的topicEdit参数 * style(TopicsTab): 调整主题名称容器的样式和输入框边框 移除主题编辑输入框的边框和阴影效果,并设置固定高度 * feat(i18n): 添加话题重命名提示文本并支持在弹窗中显示 为话题编辑功能添加多语言提示文本,说明双击可快速重命名 在PromptPopup组件中新增extraNode属性以支持显示额外提示信息 * docs(i18n): 为话题重命名提示添加"提示"前缀
This commit is contained in:
parent
9c2a88179b
commit
daaf685c9e
@ -1,6 +1,6 @@
|
|||||||
import { Input, Modal } from 'antd'
|
import { Input, Modal } from 'antd'
|
||||||
import { TextAreaProps } from 'antd/es/input'
|
import { TextAreaProps } from 'antd/es/input'
|
||||||
import { useRef, useState } from 'react'
|
import { ReactNode, useRef, useState } from 'react'
|
||||||
|
|
||||||
import { Box } from '../Layout'
|
import { Box } from '../Layout'
|
||||||
import { TopView } from '../TopView'
|
import { TopView } from '../TopView'
|
||||||
@ -11,6 +11,7 @@ interface PromptPopupShowParams {
|
|||||||
defaultValue?: string
|
defaultValue?: string
|
||||||
inputPlaceholder?: string
|
inputPlaceholder?: string
|
||||||
inputProps?: TextAreaProps
|
inputProps?: TextAreaProps
|
||||||
|
extraNode?: ReactNode
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Props extends PromptPopupShowParams {
|
interface Props extends PromptPopupShowParams {
|
||||||
@ -23,6 +24,7 @@ const PromptPopupContainer: React.FC<Props> = ({
|
|||||||
defaultValue = '',
|
defaultValue = '',
|
||||||
inputPlaceholder = '',
|
inputPlaceholder = '',
|
||||||
inputProps = {},
|
inputProps = {},
|
||||||
|
extraNode = null,
|
||||||
resolve
|
resolve
|
||||||
}) => {
|
}) => {
|
||||||
const [value, setValue] = useState(defaultValue)
|
const [value, setValue] = useState(defaultValue)
|
||||||
@ -88,6 +90,7 @@ const PromptPopupContainer: React.FC<Props> = ({
|
|||||||
rows={1}
|
rows={1}
|
||||||
{...inputProps}
|
{...inputProps}
|
||||||
/>
|
/>
|
||||||
|
{extraNode}
|
||||||
</Modal>
|
</Modal>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -584,7 +584,8 @@
|
|||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
"placeholder": "Enter new name",
|
"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": {
|
"export": {
|
||||||
"image": "Export as image",
|
"image": "Export as image",
|
||||||
|
|||||||
@ -584,7 +584,8 @@
|
|||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
"placeholder": "新しい名前を入力",
|
"placeholder": "新しい名前を入力",
|
||||||
"title": "名前を編集"
|
"title": "名前を編集",
|
||||||
|
"title_tip": "ヒント: トピック名をダブルクリックすると、直接その場で名前を変更できます"
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
"image": "画像としてエクスポート",
|
"image": "画像としてエクスポート",
|
||||||
|
|||||||
@ -584,7 +584,8 @@
|
|||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
"placeholder": "Введите новый заголовок",
|
"placeholder": "Введите новый заголовок",
|
||||||
"title": "Редактировать заголовок"
|
"title": "Редактировать заголовок",
|
||||||
|
"title_tip": "Совет: двойной щелчок по названию темы позволяет переименовать её на месте"
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
"image": "Экспорт как изображение",
|
"image": "Экспорт как изображение",
|
||||||
|
|||||||
@ -584,7 +584,8 @@
|
|||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
"placeholder": "输入新名称",
|
"placeholder": "输入新名称",
|
||||||
"title": "编辑话题名"
|
"title": "编辑话题名",
|
||||||
|
"title_tip": "提示: 双击话题名可以直接就地重命名"
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
"image": "导出为图片",
|
"image": "导出为图片",
|
||||||
|
|||||||
@ -584,7 +584,8 @@
|
|||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
"placeholder": "輸入新名稱",
|
"placeholder": "輸入新名稱",
|
||||||
"title": "編輯名稱"
|
"title": "編輯名稱",
|
||||||
|
"title_tip": "提示:雙擊話題名可以直接就地重新命名"
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
"image": "匯出為圖片",
|
"image": "匯出為圖片",
|
||||||
|
|||||||
@ -584,7 +584,8 @@
|
|||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
"placeholder": "Εισαγάγετε το νέο όνομα",
|
"placeholder": "Εισαγάγετε το νέο όνομα",
|
||||||
"title": "Επεξεργασία ονόματος θέματος"
|
"title": "Επεξεργασία ονόματος θέματος",
|
||||||
|
"title_tip": "Συμβουλές: Διπλό κλικ στο όνομα του θέματος για να το μετονομάσετε απευθείας"
|
||||||
},
|
},
|
||||||
"export": {
|
"export": {
|
||||||
"image": "Εξαγωγή ως εικόνα",
|
"image": "Εξαγωγή ως εικόνα",
|
||||||
|
|||||||
@ -584,7 +584,8 @@
|
|||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
"placeholder": "Introduce nuevo nombre",
|
"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": {
|
"export": {
|
||||||
"image": "Exportar como imagen",
|
"image": "Exportar como imagen",
|
||||||
|
|||||||
@ -584,7 +584,8 @@
|
|||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
"placeholder": "Entrez un nouveau nom",
|
"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": {
|
"export": {
|
||||||
"image": "Exporter sous forme d'image",
|
"image": "Exporter sous forme d'image",
|
||||||
|
|||||||
@ -584,7 +584,8 @@
|
|||||||
},
|
},
|
||||||
"edit": {
|
"edit": {
|
||||||
"placeholder": "Digite novo nome",
|
"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": {
|
"export": {
|
||||||
"image": "Exportar como imagem",
|
"image": "Exportar como imagem",
|
||||||
|
|||||||
@ -222,9 +222,19 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic,
|
|||||||
key: 'rename',
|
key: 'rename',
|
||||||
icon: <EditIcon size={14} />,
|
icon: <EditIcon size={14} />,
|
||||||
disabled: isRenaming(topic.id),
|
disabled: isRenaming(topic.id),
|
||||||
onClick() {
|
async onClick() {
|
||||||
setEditingTopicId(topic.id)
|
const name = await PromptPopup.show({
|
||||||
topicEdit.startEdit(topic.name)
|
title: t('chat.topics.edit.title'),
|
||||||
|
message: '',
|
||||||
|
defaultValue: topic?.name || '',
|
||||||
|
extraNode: (
|
||||||
|
<div style={{ color: 'var(--color-text-3)', marginTop: 8 }}>{t('chat.topics.edit.title_tip')}</div>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
if (name && topic?.name !== name) {
|
||||||
|
const updatedTopic = { ...topic, name, isNameManuallyEdited: true }
|
||||||
|
updateTopic(updatedTopic)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -448,7 +458,6 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic,
|
|||||||
assistants,
|
assistants,
|
||||||
assistant,
|
assistant,
|
||||||
updateTopic,
|
updateTopic,
|
||||||
topicEdit,
|
|
||||||
activeTopic.id,
|
activeTopic.id,
|
||||||
setActiveTopic,
|
setActiveTopic,
|
||||||
onPinTopic,
|
onPinTopic,
|
||||||
@ -519,7 +528,13 @@ const Topics: FC<Props> = ({ assistant: _assistant, activeTopic, setActiveTopic,
|
|||||||
onClick={(e) => e.stopPropagation()}
|
onClick={(e) => e.stopPropagation()}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<TopicName className={getTopicNameClassName()} title={topicName}>
|
<TopicName
|
||||||
|
className={getTopicNameClassName()}
|
||||||
|
title={topicName}
|
||||||
|
onDoubleClick={() => {
|
||||||
|
setEditingTopicId(topic.id)
|
||||||
|
topicEdit.startEdit(topic.name)
|
||||||
|
}}>
|
||||||
{topicName}
|
{topicName}
|
||||||
</TopicName>
|
</TopicName>
|
||||||
)}
|
)}
|
||||||
@ -622,6 +637,7 @@ const TopicNameContainer = styled.div`
|
|||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
|
height: 20px;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -675,19 +691,14 @@ const TopicName = styled.div`
|
|||||||
|
|
||||||
const TopicEditInput = styled.input`
|
const TopicEditInput = styled.input`
|
||||||
background: var(--color-background);
|
background: var(--color-background);
|
||||||
border: 1px solid var(--color-border);
|
border: none;
|
||||||
border-radius: 4px;
|
|
||||||
color: var(--color-text-1);
|
color: var(--color-text-1);
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
font-family: inherit;
|
font-family: inherit;
|
||||||
padding: 2px 6px;
|
padding: 2px 6px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
outline: none;
|
outline: none;
|
||||||
|
padding: 0;
|
||||||
&:focus {
|
|
||||||
border-color: var(--color-primary);
|
|
||||||
box-shadow: 0 0 0 2px var(--color-primary-alpha);
|
|
||||||
}
|
|
||||||
`
|
`
|
||||||
|
|
||||||
const PendingIndicator = styled.div.attrs({
|
const PendingIndicator = styled.div.attrs({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user