diff --git a/frontend/src/App.tool-center.test.ts b/frontend/src/App.tool-center.test.ts index 5ad5a57..16b7f1b 100644 --- a/frontend/src/App.tool-center.test.ts +++ b/frontend/src/App.tool-center.test.ts @@ -169,7 +169,7 @@ describe('tool center menu entries', () => { ['toggleLogPanel', 'handleToggleLogPanel();'], ['toggleTheme', 'setTheme('], ['openShortcutManager', 'setIsShortcutModalOpen(true);'], - ['toggleMacFullscreen', 'handleTitleBarWindowToggle();'], + ['toggleMacFullscreen', 'handleTitleBarWindowToggle({ allowMacNativeFullscreen: true });'], ['resetWindowZoom', 'handleManualResetWindowZoom();'], ]); @@ -183,6 +183,14 @@ describe('tool center menu entries', () => { expect(appSource).toContain('switchActiveTabByOffset, themeMode'); }); + it('keeps titlebar double-click on maximise while shortcuts may enter macOS fullscreen', () => { + expect(appSource).toContain('const handleTitleBarWindowToggle = async (options?: { allowMacNativeFullscreen?: boolean }) => {'); + expect(appSource).toContain('const allowMacNativeFullscreen = options?.allowMacNativeFullscreen === true;'); + expect(appSource).toContain('if (allowMacNativeFullscreen && useNativeMacWindowControls && isMacRuntime) {'); + expect(appSource).toContain('void handleTitleBarWindowToggle({ allowMacNativeFullscreen: false });'); + expect(getGlobalShortcutCaseBlock('toggleMacFullscreen')).toContain('handleTitleBarWindowToggle({ allowMacNativeFullscreen: true });'); + }); + it('captures global shortcuts before Monaco/editor defaults consume them', () => { expect(appSource).toContain("window.addEventListener('keydown', handleGlobalShortcut, true);"); expect(appSource).toContain("window.removeEventListener('keydown', handleGlobalShortcut, true);"); diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 57be88f..f9a2afb 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -2644,7 +2644,8 @@ function App() { } }, [securityUpdateRepairSource]); - const handleTitleBarWindowToggle = async () => { + const handleTitleBarWindowToggle = async (options?: { allowMacNativeFullscreen?: boolean }) => { + const allowMacNativeFullscreen = options?.allowMacNativeFullscreen === true; const syncWindowStateFromRuntime = async () => { try { const [isFullscreen, isMaximised] = await Promise.all([ @@ -2665,7 +2666,7 @@ function App() { void emitWindowDiagnostic('action:titlebar-toggle:after-unfullscreen'); return; } - if (useNativeMacWindowControls && isMacRuntime) { + if (allowMacNativeFullscreen && useNativeMacWindowControls && isMacRuntime) { await WindowFullscreen(); await syncWindowStateFromRuntime(); void emitWindowDiagnostic('action:titlebar-toggle:after-fullscreen'); @@ -2690,7 +2691,7 @@ function App() { if (target?.closest('[data-no-titlebar-toggle="true"]')) { return; } - void handleTitleBarWindowToggle(); + void handleTitleBarWindowToggle({ allowMacNativeFullscreen: false }); }; // handleManualResetWindowZoom 由 resetWindowZoom 快捷键(默认 Ctrl+Shift+0)触发, @@ -3080,7 +3081,7 @@ function App() { break; case 'toggleMacFullscreen': if (isMacRuntime && useNativeMacWindowControls) { - void handleTitleBarWindowToggle(); + void handleTitleBarWindowToggle({ allowMacNativeFullscreen: true }); } break; case 'resetWindowZoom':