mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-12 09:29:43 +08:00
🐛 fix(window): 修复 macOS 标题栏双击进入全屏
- 将标题栏双击与 macOS 原生全屏路径解耦 - 双击标题栏时仅执行窗口最大化或还原 - 保留快捷键触发 macOS 原生全屏的能力 - 增加工具栏测试断言覆盖双击和快捷键路径差异
This commit is contained in:
@@ -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);");
|
||||
|
||||
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user