From 0d236a94ab133591f74dff9ed867560bcf6bf8f0 Mon Sep 17 00:00:00 2001 From: ousugo Date: Thu, 20 Feb 2025 10:36:14 +0800 Subject: [PATCH] feat: Add direct topic deletion shortcut --- src/renderer/src/i18n/locales/en-us.json | 1 + src/renderer/src/i18n/locales/ja-jp.json | 1 + src/renderer/src/i18n/locales/ru-ru.json | 1 + src/renderer/src/i18n/locales/zh-cn.json | 4 +- src/renderer/src/i18n/locales/zh-tw.json | 1 + .../src/pages/home/Tabs/TopicsTab.tsx | 42 ++++++++++++++----- 6 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index 8f126924..5bcfe40c 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -140,6 +140,7 @@ "topics.title": "Topics", "topics.unpinned": "Unpinned Topics", "topics.delete.title": "Are you sure you want to delete this topic? This action cannot be undone", + "topics.delete.shortcut": "Hold {{key}} to delete directly", "translate": "Translate", "topics.prompt": "Topic Prompts", "topics.prompt.tips": "Topic Prompts: Additional supplementary prompts provided for the current topic", diff --git a/src/renderer/src/i18n/locales/ja-jp.json b/src/renderer/src/i18n/locales/ja-jp.json index 575981ce..ef90f7f2 100644 --- a/src/renderer/src/i18n/locales/ja-jp.json +++ b/src/renderer/src/i18n/locales/ja-jp.json @@ -140,6 +140,7 @@ "topics.title": "トピック", "topics.unpinned": "固定解除", "topics.delete.title": "このトピックを削除してもよろしいですか?この操作は元に戻せません", + "topics.delete.shortcut": "{{key}}キーを押しながらで直接削除", "translate": "翻訳", "topics.prompt": "トピック提示語", "topics.prompt.tips": "トピック提示語:現在のトピックに対して追加の補足提示語を提供", diff --git a/src/renderer/src/i18n/locales/ru-ru.json b/src/renderer/src/i18n/locales/ru-ru.json index b9dcee0f..b3394324 100644 --- a/src/renderer/src/i18n/locales/ru-ru.json +++ b/src/renderer/src/i18n/locales/ru-ru.json @@ -140,6 +140,7 @@ "topics.title": "Топики", "topics.unpinned": "Открепленные темы", "topics.delete.title": "Вы уверены, что хотите удалить этот топик? Это действие нельзя отменить", + "topics.delete.shortcut": "Удерживайте {{key}} для мгновенного удаления", "translate": "Перевести", "topics.prompt": "Тематические подсказки", "topics.prompt.tips": "Тематические подсказки: Дополнительные подсказки, предоставленные для текущей темы", diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index 04e469cd..87cb3e8c 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -142,10 +142,10 @@ "topics.title": "话题", "topics.unpinned": "取消固定", "topics.delete.title": "确定要删除此话题吗?此操作无法撤销", + "topics.delete.shortcut": "按住 {{key}} 可直接删除", "translate": "翻译", "topics.prompt": "话题提示词", - "topics.prompt.tips": "话题提示词: 针对当前话题提供额外的补充提示词", - "topics.prompt.edit.title": "编辑话题提示词" + "topics.prompt.tips": "话题提示词: 针对当前话题提供额外的补充提示词" }, "common": { "add": "添加", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index 14fb0b0b..e52f0430 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -140,6 +140,7 @@ "topics.title": "話題", "topics.unpinned": "取消固定", "topics.delete.title": "確定要刪除此話題嗎?此操作無法撤銷", + "topics.delete.shortcut": "按住 {{key}} 可直接刪除", "translate": "翻譯", "topics.prompt": "話題提示詞", "topics.prompt.tips": "話題提示詞:針對目前話題提供額外的補充提示詞", diff --git a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx index 543d04fa..9ac87fc4 100644 --- a/src/renderer/src/pages/home/Tabs/TopicsTab.tsx +++ b/src/renderer/src/pages/home/Tabs/TopicsTab.tsx @@ -11,6 +11,7 @@ import { import DragableList from '@renderer/components/DragableList' import PromptPopup from '@renderer/components/Popups/PromptPopup' import Scrollbar from '@renderer/components/Scrollbar' +import { isMac } from '@renderer/config/constant' import { useAssistant, useAssistants } from '@renderer/hooks/useAssistant' import { modelGenerating } from '@renderer/hooks/useRuntime' import { useSettings } from '@renderer/hooks/useSettings' @@ -260,16 +261,37 @@ const Topics: FC = ({ assistant: _assistant, activeTopic, setActiveTopic removeTopic(topic) }} onCancel={(e) => e?.stopPropagation()}> - { - e.stopPropagation() - if (assistant.topics.length === 1) { - return onClearMessages() - } - }}> - - + +
+ {t('chat.topics.delete.shortcut', { + key: isMac ? '⌘' : 'Ctrl' + })} +
+ + }> + { + e.stopPropagation() + if (assistant.topics.length === 1) { + return onClearMessages() + } + if (e.ctrlKey || e.metaKey) { + await modelGenerating() + const index = findIndex(assistant.topics, (t) => t.id === topic.id) + setActiveTopic( + assistant.topics[index + 1 === assistant.topics.length ? index - 1 : index + 1] + ) + removeTopic(topic) + } + }}> + + +
)}