-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpreload.js
More file actions
19 lines (18 loc) · 987 Bytes
/
preload.js
File metadata and controls
19 lines (18 loc) · 987 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('electronAPI', {
startVoting: (ids, outputDir, folderStructure, filenamePattern) => ipcRenderer.invoke('start-voting', { ids, outputDir, folderStructure, filenamePattern }),
stopVoting: () => ipcRenderer.invoke('stop-voting'),
selectDirectory: () => ipcRenderer.invoke('select-directory'),
getConfig: () => ipcRenderer.invoke('get-config'),
saveConfig: (config) => ipcRenderer.invoke('save-config', config),
openExternal: (url) => ipcRenderer.invoke('open-external', url),
openAbout: () => ipcRenderer.invoke('open-about'),
getAppVersion: () => ipcRenderer.invoke('get-app-version'),
onLog: (callback) => ipcRenderer.on('log', (_event, msg, type) => {
callback(String(msg), type);
}),
onProgress: (callback) => ipcRenderer.on('progress', (_event, value) => {
// Deep copy to ensure serializable data only
callback(JSON.parse(JSON.stringify(value)));
}),
});