Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): 修复全屏桥不兼容导致的界面崩溃
Mimo45c53c7522c0
diff --git a/apps/desktop/src/renderer/hooks/__tests__/useMacFullscreen.test.ts b/apps/desktop/src/renderer/hooks/__tests__/useMacFullscreen.test.tsindex 0cb7d666b6..f18217996a 100644--- a/apps/desktop/src/renderer/hooks/__tests__/useMacFullscreen.test.ts+++ b/apps/desktop/src/renderer/hooks/__tests__/useMacFullscreen.test.ts@@ -11,10 +11,17 @@ describe('useMacFullscreen', () => {delete (window as { electronAPI?: unknown }).electronAPI;});- it('does not crash when an older preload has no fullscreen bridge', () => {+ it.each([+ ['missing', { platform: 'darwin' }],+ ['incompatible', {+ platform: 'darwin',+ getFullscreenState: false,+ onFullscreenChange: {},+ }],+ ])('does not crash when an older preload has a %s fullscreen bridge', (_name, electronAPI) => {Object.defineProperty(window, 'electronAPI', {configurable: true,- value: { platform: 'darwin' },+ value: electronAPI,});const { result } = renderHook(() => useMacFullscreen());diff --git a/apps/desktop/src/renderer/hooks/useMacFullscreen.ts b/apps/desktop/src/renderer/hooks/useMacFullscreen.tsindex 5245efab59..85208ccabb 100644--- a/apps/desktop/src/renderer/hooks/useMacFullscreen.ts+++ b/apps/desktop/src/renderer/hooks/useMacFullscreen.ts@@ -21,18 +21,22 @@ export function useMacFullscreen(): { isMac: boolean; isFullscreen: boolean } {useEffect(() => {if (!isMac) return;let cancelled = false;- window.electronAPI?.getFullscreenState?.().then((fs) => {- if (!cancelled) setIsFullscreen(fs);- });+ const api = window.electronAPI;+ if (typeof api?.getFullscreenState === 'function') {+ void api.getFullscreenState().then((fs) => {+ if (!cancelled) setIsFullscreen(fs);+ });+ }// Older packaged preload scripts (or a renderer/preload mismatch during an- // update) may not expose the fullscreen bridge yet. The layout can safely- // fall back to the non-fullscreen spacing; it must not crash the window.- const unsub = window.electronAPI?.onFullscreenChange?.((fs: boolean) => {- setIsFullscreen(fs);- });+ // update) may expose a missing or incompatible fullscreen bridge. The layout+ // can safely fall back to the non-fullscreen spacing; it must not crash.+ const unsub =+ typeof api?.onFullscreenChange === 'function'+ ? api.onFullscreenChange((fs: boolean) => setIsFullscreen(fs))+ : undefined;return () => {cancelled = true;- unsub?.();+ if (typeof unsub === 'function') unsub();};}, [isMac]);