-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpreload.js
More file actions
28 lines (25 loc) · 1.04 KB
/
Copy pathpreload.js
File metadata and controls
28 lines (25 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
isElectron: true,
onUpdateAvailable: (callback) => ipcRenderer.on('update-available', callback),
onUpdateDownloaded: (callback) => ipcRenderer.on('update-downloaded', callback),
getScreenSources: async (options = {}) => {
const {
types = ['screen', 'window'],
thumbnailSize = { width: 480, height: 270 },
fetchWindowIcons = true,
} = options ?? {};
try {
return await ipcRenderer.invoke('desktop-capturer-get-sources', {
types,
thumbnailSize,
fetchWindowIcons,
});
} catch (error) {
console.error('[Electron preload] Failed to fetch screen sources', error);
throw error;
}
},
});
// Примечание: для splash screen мы используем прямой ipcRenderer в splash.html
// так как это отдельное окно которое не требует такой же изоляции как основное приложение