From c2d5d5492291920b0d1385cdefcab4c367428c83 Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Mon, 6 Jan 2025 16:29:39 +0800 Subject: [PATCH] feat: add search message shortcut #366 --- src/renderer/src/i18n/locales/en-us.json | 3 ++- src/renderer/src/i18n/locales/ja-jp.json | 3 ++- src/renderer/src/i18n/locales/ru-ru.json | 3 ++- src/renderer/src/i18n/locales/zh-cn.json | 3 ++- src/renderer/src/i18n/locales/zh-tw.json | 3 ++- src/renderer/src/pages/home/Navbar.tsx | 4 ++++ src/renderer/src/store/index.ts | 2 +- src/renderer/src/store/migrate.ts | 12 ++++++++++++ src/renderer/src/store/shortcuts.ts | 7 +++++++ 9 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/renderer/src/i18n/locales/en-us.json b/src/renderer/src/i18n/locales/en-us.json index 64e959a61c..f01e660991 100644 --- a/src/renderer/src/i18n/locales/en-us.json +++ b/src/renderer/src/i18n/locales/en-us.json @@ -501,7 +501,8 @@ "clear_shortcut": "Clear Shortcut", "toggle_show_assistants": "Toggle Assistants", "toggle_show_topics": "Toggle Topics", - "copy_last_message": "Copy Last Message" + "copy_last_message": "Copy Last Message", + "search_message": "Search Message" }, "theme.auto": "Auto", "theme.dark": "Dark", diff --git a/src/renderer/src/i18n/locales/ja-jp.json b/src/renderer/src/i18n/locales/ja-jp.json index 2e69952ce5..a555def5bc 100644 --- a/src/renderer/src/i18n/locales/ja-jp.json +++ b/src/renderer/src/i18n/locales/ja-jp.json @@ -487,7 +487,8 @@ "clear_shortcut": "ショートカットをクリア", "toggle_show_assistants": "アシスタントの表示を切り替え", "toggle_show_topics": "トピックの表示を切り替え", - "copy_last_message": "最後のメッセージをコピー" + "copy_last_message": "最後のメッセージをコピー", + "search_message": "メッセージを検索" }, "theme.auto": "自動", "theme.dark": "ダークテーマ", diff --git a/src/renderer/src/i18n/locales/ru-ru.json b/src/renderer/src/i18n/locales/ru-ru.json index b3539e92b6..e67aab9309 100644 --- a/src/renderer/src/i18n/locales/ru-ru.json +++ b/src/renderer/src/i18n/locales/ru-ru.json @@ -501,7 +501,8 @@ "clear_shortcut": "Очистить сочетание клавиш", "toggle_show_assistants": "Переключить отображение ассистентов", "toggle_show_topics": "Переключить отображение топиков", - "copy_last_message": "Копировать последнее сообщение" + "copy_last_message": "Копировать последнее сообщение", + "search_message": "Поиск сообщения" }, "theme.auto": "Автоматически", "theme.dark": "Темная", diff --git a/src/renderer/src/i18n/locales/zh-cn.json b/src/renderer/src/i18n/locales/zh-cn.json index 07c37d88a1..757b8ee13f 100644 --- a/src/renderer/src/i18n/locales/zh-cn.json +++ b/src/renderer/src/i18n/locales/zh-cn.json @@ -490,7 +490,8 @@ "clear_shortcut": "清除快捷键", "toggle_show_assistants": "切换助手显示", "toggle_show_topics": "切换话题显示", - "copy_last_message": "复制上一条消息" + "copy_last_message": "复制上一条消息", + "search_message": "搜索消息" }, "theme.auto": "跟随系统", "theme.dark": "深色主题", diff --git a/src/renderer/src/i18n/locales/zh-tw.json b/src/renderer/src/i18n/locales/zh-tw.json index e5dcf52872..7c5b6b79da 100644 --- a/src/renderer/src/i18n/locales/zh-tw.json +++ b/src/renderer/src/i18n/locales/zh-tw.json @@ -489,7 +489,8 @@ "clear_shortcut": "清除快捷鍵", "toggle_show_assistants": "切換助手顯示", "toggle_show_topics": "切換話題顯示", - "copy_last_message": "複製上一条消息" + "copy_last_message": "複製上一条消息", + "search_message": "搜索消息" }, "theme.auto": "自動", "theme.dark": "深色主題", diff --git a/src/renderer/src/pages/home/Navbar.tsx b/src/renderer/src/pages/home/Navbar.tsx index beefff4899..f2eb5785bb 100644 --- a/src/renderer/src/pages/home/Navbar.tsx +++ b/src/renderer/src/pages/home/Navbar.tsx @@ -40,6 +40,10 @@ const HeaderNavbar: FC = ({ activeAssistant }) => { } }) + useShortcut('search_message', () => { + SearchPopup.show() + }) + return ( {showAssistants && ( diff --git a/src/renderer/src/store/index.ts b/src/renderer/src/store/index.ts index 1e9c599fd2..fd488b0b33 100644 --- a/src/renderer/src/store/index.ts +++ b/src/renderer/src/store/index.ts @@ -28,7 +28,7 @@ const persistedReducer = persistReducer( { key: 'cherry-studio', storage, - version: 51, + version: 52, blacklist: ['runtime'], migrate }, diff --git a/src/renderer/src/store/migrate.ts b/src/renderer/src/store/migrate.ts index 21148fb66a..1dd66e7eea 100644 --- a/src/renderer/src/store/migrate.ts +++ b/src/renderer/src/store/migrate.ts @@ -775,6 +775,18 @@ const migrateConfig = { '51': (state: RootState) => { state.settings.topicNamingPrompt = '' return state + }, + '52': (state: RootState) => { + if (state.shortcuts) { + state.shortcuts.shortcuts.push({ + key: 'search_message', + shortcut: [isMac ? 'Command' : 'Ctrl', 'F'], + editable: true, + enabled: true, + system: false + }) + } + return state } } diff --git a/src/renderer/src/store/shortcuts.ts b/src/renderer/src/store/shortcuts.ts index 93f91ade73..39ccbfd02e 100644 --- a/src/renderer/src/store/shortcuts.ts +++ b/src/renderer/src/store/shortcuts.ts @@ -44,6 +44,13 @@ const initialState: ShortcutsState = { editable: true, enabled: false, system: false + }, + { + key: 'search_message', + shortcut: [isMac ? 'Command' : 'Ctrl', 'F'], + editable: true, + enabled: true, + system: false } ] }