feat: add translations and reset functionality for new features
This commit is contained in:
parent
7dacd58821
commit
cd3c053f81
@ -456,7 +456,9 @@
|
||||
"zoom_reset": "Reset Zoom",
|
||||
"show_app": "Show App",
|
||||
"reset_defaults": "Reset Defaults",
|
||||
"press_shortcut": "Press Shortcut"
|
||||
"reset_defaults_confirm": "Are you sure you want to reset all shortcuts?",
|
||||
"press_shortcut": "Press Shortcut",
|
||||
"alt_warning": "Mac does not support the Alt key"
|
||||
},
|
||||
"theme.auto": "Auto",
|
||||
"theme.dark": "Dark",
|
||||
|
||||
@ -456,7 +456,9 @@
|
||||
"zoom_reset": "Сбросить масштаб",
|
||||
"show_app": "Показать приложение",
|
||||
"reset_defaults": "Сбросить настройки по умолчанию",
|
||||
"press_shortcut": "Нажмите сочетание клавиш"
|
||||
"reset_defaults_confirm": "Вы уверены, что хотите сбросить все горячие клавиши?",
|
||||
"press_shortcut": "Нажмите сочетание клавиш",
|
||||
"alt_warning": "Mac не поддерживает Alt"
|
||||
},
|
||||
"theme.auto": "Автоматически",
|
||||
"theme.dark": "Темная",
|
||||
|
||||
@ -444,7 +444,9 @@
|
||||
"zoom_reset": "重置缩放",
|
||||
"show_app": "显示应用",
|
||||
"reset_defaults": "重置默认快捷键",
|
||||
"press_shortcut": "按下快捷键"
|
||||
"reset_defaults_confirm": "确定要重置所有快捷键吗?",
|
||||
"press_shortcut": "按下快捷键",
|
||||
"alt_warning": "Mac 系统不支持 Alt 键"
|
||||
},
|
||||
"theme.auto": "跟随系统",
|
||||
"theme.dark": "深色主题",
|
||||
|
||||
@ -444,7 +444,9 @@
|
||||
"zoom_reset": "重置縮放",
|
||||
"show_app": "顯示應用",
|
||||
"reset_defaults": "重置預設快捷鍵",
|
||||
"press_shortcut": "按下快捷鍵"
|
||||
"reset_defaults_confirm": "確定要重置所有快捷鍵嗎?",
|
||||
"press_shortcut": "按下快捷鍵",
|
||||
"alt_warning": "Mac 系統不支持 Alt 鍵"
|
||||
},
|
||||
"theme.auto": "自動",
|
||||
"theme.dark": "深色主題",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import { UndoOutlined } from '@ant-design/icons'
|
||||
import { HStack } from '@renderer/components/Layout'
|
||||
import { isMac } from '@renderer/config/constant'
|
||||
import { useTheme } from '@renderer/context/ThemeProvider'
|
||||
import { useAppDispatch, useAppSelector } from '@renderer/store'
|
||||
@ -62,6 +63,15 @@ const ShortcutSettings: FC = () => {
|
||||
const isValidShortcut = (keys: string[]): boolean => {
|
||||
const hasModifier = keys.some((key) => ['Control', 'Ctrl', 'Command', 'Alt', 'Shift'].includes(key))
|
||||
const hasNonModifier = keys.some((key) => !['Control', 'Ctrl', 'Command', 'Alt', 'Shift'].includes(key))
|
||||
|
||||
if (isMac && keys.includes('Alt')) {
|
||||
window.message.warning({
|
||||
content: t('settings.shortcuts.alt_warning'),
|
||||
key: 'shortcut-alt-warning'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
return hasModifier && hasNonModifier && keys.length >= 2
|
||||
}
|
||||
|
||||
@ -104,6 +114,7 @@ const ShortcutSettings: FC = () => {
|
||||
if (e.shiftKey) keys.push('Shift')
|
||||
|
||||
const key = e.key
|
||||
|
||||
if (!['Control', 'Alt', 'Shift', 'Meta'].includes(key)) {
|
||||
keys.push(key.toUpperCase())
|
||||
}
|
||||
@ -125,6 +136,14 @@ const ShortcutSettings: FC = () => {
|
||||
setEditingKey(null)
|
||||
}
|
||||
|
||||
const handleResetAllShortcuts = () => {
|
||||
window.modal.confirm({
|
||||
title: t('settings.shortcuts.reset_defaults_confirm'),
|
||||
centered: true,
|
||||
onOk: () => dispatch(resetShortcuts())
|
||||
})
|
||||
}
|
||||
|
||||
const columns: ColumnsType<ShortcutItem> = [
|
||||
{
|
||||
title: t('settings.shortcuts.action'),
|
||||
@ -203,9 +222,9 @@ const ShortcutSettings: FC = () => {
|
||||
showHeader={false}
|
||||
/>
|
||||
<SettingDivider style={{ marginBottom: 0 }} />
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', padding: '16px 0' }}>
|
||||
<Button onClick={() => dispatch(resetShortcuts())}>{t('settings.shortcuts.reset_defaults')}</Button>
|
||||
</div>
|
||||
<HStack justifyContent="flex-end" padding="16px 0">
|
||||
<Button onClick={handleResetAllShortcuts}>{t('settings.shortcuts.reset_defaults')}</Button>
|
||||
</HStack>
|
||||
</SettingGroup>
|
||||
</SettingContainer>
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user