feat: add shortcut for assistant and topic show
This commit is contained in:
parent
7153996c35
commit
408976e5dc
@ -62,6 +62,7 @@ electronDownload:
|
||||
afterSign: scripts/notarize.js
|
||||
releaseInfo:
|
||||
releaseNotes: |
|
||||
增加快捷键切换助手和话题显示
|
||||
历史消息懒加载 by @1355873789
|
||||
更快的应用更新下载速度 by @1355873789
|
||||
更加清晰的模型分组
|
||||
|
||||
@ -95,18 +95,21 @@ export const ZOOM_SHORTCUTS = [
|
||||
key: 'zoom_in',
|
||||
shortcut: ['CommandOrControl', '='],
|
||||
editable: false,
|
||||
enabled: true
|
||||
enabled: true,
|
||||
system: true
|
||||
},
|
||||
{
|
||||
key: 'zoom_out',
|
||||
shortcut: ['CommandOrControl', '-'],
|
||||
editable: false,
|
||||
enabled: true
|
||||
enabled: true,
|
||||
system: true
|
||||
},
|
||||
{
|
||||
key: 'zoom_reset',
|
||||
shortcut: ['CommandOrControl', '0'],
|
||||
editable: false,
|
||||
enabled: true
|
||||
enabled: true,
|
||||
system: true
|
||||
}
|
||||
]
|
||||
|
||||
@ -77,7 +77,10 @@ export class ConfigManager {
|
||||
}
|
||||
|
||||
setShortcuts(shortcuts: Shortcut[]) {
|
||||
this.store.set('shortcuts', shortcuts)
|
||||
this.store.set(
|
||||
'shortcuts',
|
||||
shortcuts.filter((shortcut) => shortcut.system)
|
||||
)
|
||||
this.notifySubscribers('shortcuts', shortcuts)
|
||||
}
|
||||
}
|
||||
|
||||
@ -107,12 +107,6 @@ body[theme-mode='light'] {
|
||||
--chat-background-user: #95ec69;
|
||||
--chat-background-assistant: #ffffff;
|
||||
--chat-text-user: var(--color-text);
|
||||
|
||||
#content-container {
|
||||
box-shadow:
|
||||
0 4px 24px -4px rgba(0, 0, 0, 0.08),
|
||||
0 2px 12px -2px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
}
|
||||
|
||||
*,
|
||||
@ -173,15 +167,13 @@ body,
|
||||
#content-container {
|
||||
background-color: var(--color-background);
|
||||
border-top: 0.5px solid var(--color-border);
|
||||
box-shadow:
|
||||
0 4px 28px -4px rgba(0, 0, 0, 0.3),
|
||||
0 2px 16px -2px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
body[os='mac'] {
|
||||
#content-container {
|
||||
border-top-left-radius: 12px;
|
||||
border-left: 0.5px solid var(--color-border);
|
||||
box-shadow: -2px 0px 24px -4px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,8 +14,8 @@ body[theme-mode='light'] {
|
||||
|
||||
/* 全局初始化滚动条样式 */
|
||||
::-webkit-scrollbar {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
|
||||
@ -471,7 +471,9 @@
|
||||
"press_shortcut": "Press Shortcut",
|
||||
"alt_warning": "Mac does not support Option + letters as shortcuts",
|
||||
"reset_to_default": "Reset to Default",
|
||||
"clear_shortcut": "Clear Shortcut"
|
||||
"clear_shortcut": "Clear Shortcut",
|
||||
"toggle_show_assistants": "Toggle Assistants",
|
||||
"toggle_show_topics": "Toggle Topics"
|
||||
},
|
||||
"theme.auto": "Auto",
|
||||
"theme.dark": "Dark",
|
||||
|
||||
@ -471,7 +471,9 @@
|
||||
"press_shortcut": "Нажмите сочетание клавиш",
|
||||
"alt_warning": "Mac не поддерживает Option + буквы как горячие клавиши",
|
||||
"reset_to_default": "Сбросить настройки по умолчанию",
|
||||
"clear_shortcut": "Очистить сочетание клавиш"
|
||||
"clear_shortcut": "Очистить сочетание клавиш",
|
||||
"toggle_show_assistants": "Переключить отображение ассистентов",
|
||||
"toggle_show_topics": "Переключить отображение топиков"
|
||||
},
|
||||
"theme.auto": "Автоматически",
|
||||
"theme.dark": "Темная",
|
||||
|
||||
@ -459,7 +459,9 @@
|
||||
"press_shortcut": "按下快捷键",
|
||||
"alt_warning": "Mac 系统不能使用 Option + 字母作为快捷键",
|
||||
"reset_to_default": "重置为默认",
|
||||
"clear_shortcut": "清除快捷键"
|
||||
"clear_shortcut": "清除快捷键",
|
||||
"toggle_show_assistants": "切换助手显示",
|
||||
"toggle_show_topics": "切换话题显示"
|
||||
},
|
||||
"theme.auto": "跟随系统",
|
||||
"theme.dark": "深色主题",
|
||||
|
||||
@ -459,7 +459,9 @@
|
||||
"press_shortcut": "按下快捷鍵",
|
||||
"alt_warning": "Mac 不能使用 Option + 字母作為快捷鍵",
|
||||
"reset_to_default": "重置為預設",
|
||||
"clear_shortcut": "清除快捷鍵"
|
||||
"clear_shortcut": "清除快捷鍵",
|
||||
"toggle_show_assistants": "切換助手顯示",
|
||||
"toggle_show_topics": "切換話題顯示"
|
||||
},
|
||||
"theme.auto": "自動",
|
||||
"theme.dark": "深色主題",
|
||||
|
||||
@ -6,7 +6,9 @@ import SearchPopup from '@renderer/components/Popups/SearchPopup'
|
||||
import { isMac, isWindows } from '@renderer/config/constant'
|
||||
import { useAssistant } from '@renderer/hooks/useAssistant'
|
||||
import { useSettings } from '@renderer/hooks/useSettings'
|
||||
import { useShortcut } from '@renderer/hooks/useShortcuts'
|
||||
import { useShowAssistants, useShowTopics } from '@renderer/hooks/useStore'
|
||||
import { EVENT_NAMES, EventEmitter } from '@renderer/services/EventService'
|
||||
import { Assistant, Topic } from '@renderer/types'
|
||||
import { FC } from 'react'
|
||||
import styled from 'styled-components'
|
||||
@ -25,6 +27,18 @@ const HeaderNavbar: FC<Props> = ({ activeAssistant }) => {
|
||||
const { topicPosition } = useSettings()
|
||||
const { showTopics, toggleShowTopics } = useShowTopics()
|
||||
|
||||
useShortcut('toggle_show_assistants', () => {
|
||||
toggleShowAssistants()
|
||||
})
|
||||
|
||||
useShortcut('toggle_show_topics', () => {
|
||||
if (topicPosition === 'right') {
|
||||
toggleShowTopics()
|
||||
} else {
|
||||
EventEmitter.emit(EVENT_NAMES.SHOW_TOPIC_SIDEBAR)
|
||||
}
|
||||
})
|
||||
|
||||
return (
|
||||
<Navbar>
|
||||
{showAssistants && (
|
||||
|
||||
@ -26,7 +26,7 @@ const persistedReducer = persistReducer(
|
||||
{
|
||||
key: 'cherry-studio',
|
||||
storage,
|
||||
version: 47,
|
||||
version: 48,
|
||||
blacklist: ['runtime'],
|
||||
migrate
|
||||
},
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import { isMac } from '@renderer/config/constant'
|
||||
import { SYSTEM_MODELS } from '@renderer/config/models'
|
||||
import { TRANSLATE_PROMPT } from '@renderer/config/prompts'
|
||||
import db from '@renderer/databases'
|
||||
@ -726,6 +727,26 @@ const migrateConfig = {
|
||||
})
|
||||
})
|
||||
return state
|
||||
},
|
||||
'48': (state: RootState) => {
|
||||
state.shortcuts.shortcuts.forEach((shortcut) => {
|
||||
shortcut.system = shortcut.key !== 'new_topic'
|
||||
})
|
||||
state.shortcuts.shortcuts.push({
|
||||
key: 'toggle_show_assistants',
|
||||
shortcut: [isMac ? 'Command' : 'Ctrl', '['],
|
||||
editable: true,
|
||||
enabled: true,
|
||||
system: false
|
||||
})
|
||||
state.shortcuts.shortcuts.push({
|
||||
key: 'toggle_show_topics',
|
||||
shortcut: [isMac ? 'Command' : 'Ctrl', ']'],
|
||||
editable: true,
|
||||
enabled: true,
|
||||
system: false
|
||||
})
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -10,17 +10,33 @@ export interface ShortcutsState {
|
||||
const initialState: ShortcutsState = {
|
||||
shortcuts: [
|
||||
...ZOOM_SHORTCUTS,
|
||||
{
|
||||
key: 'new_topic',
|
||||
shortcut: [isMac ? 'Command' : 'Ctrl', 'N'],
|
||||
editable: true,
|
||||
enabled: true
|
||||
},
|
||||
{
|
||||
key: 'show_app',
|
||||
shortcut: [],
|
||||
editable: true,
|
||||
enabled: true
|
||||
enabled: true,
|
||||
system: true
|
||||
},
|
||||
{
|
||||
key: 'new_topic',
|
||||
shortcut: [isMac ? 'Command' : 'Ctrl', 'N'],
|
||||
editable: true,
|
||||
enabled: true,
|
||||
system: false
|
||||
},
|
||||
{
|
||||
key: 'toggle_show_assistants',
|
||||
shortcut: [isMac ? 'Command' : 'Ctrl', '['],
|
||||
editable: true,
|
||||
enabled: true,
|
||||
system: false
|
||||
},
|
||||
{
|
||||
key: 'toggle_show_topics',
|
||||
shortcut: [isMac ? 'Command' : 'Ctrl', ']'],
|
||||
editable: true,
|
||||
enabled: true,
|
||||
system: false
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -29,7 +45,8 @@ const getSerializableShortcuts = (shortcuts: Shortcut[]) => {
|
||||
return shortcuts.map((shortcut) => ({
|
||||
key: shortcut.key,
|
||||
shortcut: [...shortcut.shortcut],
|
||||
enabled: shortcut.enabled
|
||||
enabled: shortcut.enabled,
|
||||
system: shortcut.system
|
||||
}))
|
||||
}
|
||||
|
||||
|
||||
@ -169,4 +169,5 @@ export interface Shortcut {
|
||||
shortcut: string[]
|
||||
editable: boolean
|
||||
enabled: boolean
|
||||
system: boolean
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user