feat: Enable conditional settings shortcut based on user preferences

This commit is contained in:
ousugo 2025-03-05 00:28:43 +08:00 committed by 亢奋猫
parent b9b8148fba
commit 4d73ae1eea

View File

@ -1,9 +1,13 @@
import { useAppSelector } from '@renderer/store'
import { useHotkeys } from 'react-hotkeys-hook'
import { useLocation, useNavigate } from 'react-router-dom'
const NavigationHandler: React.FC = () => {
const location = useLocation()
const navigate = useNavigate()
const showSettingsShortcutEnabled = useAppSelector(
(state) => state.shortcuts.shortcuts.find((s) => s.key === 'show_settings')?.enabled
)
useHotkeys(
'meta+, ! ctrl+,',
@ -13,7 +17,12 @@ const NavigationHandler: React.FC = () => {
}
navigate('/settings/provider')
},
{ splitKey: '!', enableOnContentEditable: true, enableOnFormTags: true }
{
splitKey: '!',
enableOnContentEditable: true,
enableOnFormTags: true,
enabled: showSettingsShortcutEnabled
}
)
return null