From c9b60746268c47670cb47061a1db5efb0d43a679 Mon Sep 17 00:00:00 2001 From: auberginewly <3127221787@qq.com> Date: Sun, 10 May 2026 05:24:19 +0800 Subject: [PATCH] fix(electron): add screen and display-capture to Electron permission allowlists setPermissionCheckHandler and setPermissionRequestHandler only allowed ["media", "audioCapture", "microphone", "videoCapture", "camera"], causing any renderer-side getUserMedia/desktopCapturer request using a screen source to be silently denied by Electron before macOS TCC is ever consulted. Fix: add "screen" and "display-capture" to both handler allowlists. --- electron/main.ts | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/electron/main.ts b/electron/main.ts index 007df33..cf20b5a 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -449,14 +449,30 @@ app.whenReady().then(async () => { app.dock?.show(); } - // Allow microphone/media permission checks + // Allow microphone/media/screen permission checks session.defaultSession.setPermissionCheckHandler((_webContents, permission) => { - const allowed = ["media", "audioCapture", "microphone", "videoCapture", "camera"]; + const allowed = [ + "media", + "audioCapture", + "microphone", + "videoCapture", + "camera", + "screen", + "display-capture", + ]; return allowed.includes(permission); }); session.defaultSession.setPermissionRequestHandler((_webContents, permission, callback) => { - const allowed = ["media", "audioCapture", "microphone", "videoCapture", "camera"]; + const allowed = [ + "media", + "audioCapture", + "microphone", + "videoCapture", + "camera", + "screen", + "display-capture", + ]; callback(allowed.includes(permission)); });