mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-07 08:22:42 +08:00
✨ feat(shortcut): 将 macOS 全屏切换快捷键注册到快捷键管理面板
- 新增 toggleMacFullscreen action 到 shortcuts.ts - 新增 platformOnly 字段支持按平台过滤快捷键显示 - 默认绑定 Ctrl+Meta+F,仅 macOS 下显示 - 移除 App.tsx 中的硬编码全屏快捷键判断,统一走 shortcuts 系统
This commit is contained in:
@@ -1 +1 @@
|
||||
594ebbc6a946fc76ba11bee7b3f53282
|
||||
0f60775ad0a6b251a4320748f196a712
|
||||
@@ -1372,13 +1372,6 @@ function App() {
|
||||
|
||||
useEffect(() => {
|
||||
const handleGlobalShortcut = (event: KeyboardEvent) => {
|
||||
if (shouldHandleMacNativeFullscreenShortcut(isMacRuntime, useNativeMacWindowControls, event)) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
void handleTitleBarWindowToggle();
|
||||
return;
|
||||
}
|
||||
|
||||
const matchedAction = SHORTCUT_ACTION_ORDER.find((action) => {
|
||||
const binding = shortcutOptions[action];
|
||||
if (!binding?.enabled) {
|
||||
@@ -1416,6 +1409,11 @@ function App() {
|
||||
case 'openShortcutManager':
|
||||
setIsShortcutModalOpen(true);
|
||||
break;
|
||||
case 'toggleMacFullscreen':
|
||||
if (isMacRuntime && useNativeMacWindowControls) {
|
||||
void handleTitleBarWindowToggle();
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2145,6 +2143,9 @@ function App() {
|
||||
</div>
|
||||
{SHORTCUT_ACTION_ORDER.map((action) => {
|
||||
const meta = SHORTCUT_ACTION_META[action];
|
||||
if (meta.platformOnly === 'mac' && !isMacRuntime) {
|
||||
return null;
|
||||
}
|
||||
const binding = shortcutOptions[action] ?? { combo: '', enabled: false };
|
||||
const isCapturing = capturingShortcutAction === action;
|
||||
return (
|
||||
|
||||
@@ -6,7 +6,8 @@ export type ShortcutAction =
|
||||
| 'newQueryTab'
|
||||
| 'toggleLogPanel'
|
||||
| 'toggleTheme'
|
||||
| 'openShortcutManager';
|
||||
| 'openShortcutManager'
|
||||
| 'toggleMacFullscreen';
|
||||
|
||||
export interface ShortcutBinding {
|
||||
combo: string;
|
||||
@@ -19,6 +20,7 @@ export interface ShortcutActionMeta {
|
||||
label: string;
|
||||
description: string;
|
||||
allowInEditable?: boolean;
|
||||
platformOnly?: 'mac';
|
||||
}
|
||||
|
||||
const MODIFIER_ORDER = ['Ctrl', 'Meta', 'Alt', 'Shift'] as const;
|
||||
@@ -76,6 +78,7 @@ export const SHORTCUT_ACTION_ORDER: ShortcutAction[] = [
|
||||
'toggleLogPanel',
|
||||
'toggleTheme',
|
||||
'openShortcutManager',
|
||||
'toggleMacFullscreen',
|
||||
];
|
||||
|
||||
export const SHORTCUT_ACTION_META: Record<ShortcutAction, ShortcutActionMeta> = {
|
||||
@@ -105,6 +108,11 @@ export const SHORTCUT_ACTION_META: Record<ShortcutAction, ShortcutActionMeta> =
|
||||
description: '打开快捷键设置面板',
|
||||
allowInEditable: true,
|
||||
},
|
||||
toggleMacFullscreen: {
|
||||
label: '切换原生全屏',
|
||||
description: 'macOS 原生窗口控制模式下的全屏切换(⌃⌘F)',
|
||||
platformOnly: 'mac',
|
||||
},
|
||||
};
|
||||
|
||||
export const DEFAULT_SHORTCUT_OPTIONS: ShortcutOptions = {
|
||||
@@ -114,6 +122,7 @@ export const DEFAULT_SHORTCUT_OPTIONS: ShortcutOptions = {
|
||||
toggleLogPanel: { combo: 'Ctrl+Shift+L', enabled: true },
|
||||
toggleTheme: { combo: 'Ctrl+Shift+D', enabled: true },
|
||||
openShortcutManager: { combo: 'Ctrl+,', enabled: true },
|
||||
toggleMacFullscreen: { combo: 'Ctrl+Meta+F', enabled: true },
|
||||
};
|
||||
|
||||
const normalizeKeyToken = (value: string): string => {
|
||||
|
||||
Reference in New Issue
Block a user