This commit is contained in:
parent
24975c2e0d
commit
3acd082fb0
28 changed files with 3454 additions and 836 deletions
|
|
@ -1,18 +1,20 @@
|
|||
const { contextBridge, ipcRenderer } = require('electron');
|
||||
|
||||
function onIpc(channel, callback) {
|
||||
const listener = (_event, payload) => callback(payload);
|
||||
ipcRenderer.on(channel, listener);
|
||||
return () => ipcRenderer.removeListener(channel, listener);
|
||||
}
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
copyToClipboard: (text) => ipcRenderer.invoke('clipboard-write', text),
|
||||
getConfig: () => ipcRenderer.invoke('get-config'),
|
||||
storageGet: (key) => ipcRenderer.invoke('storage-get', key),
|
||||
storageSet: (key, value) => ipcRenderer.invoke('storage-set', key, value),
|
||||
storageRemove: (key) => ipcRenderer.invoke('storage-remove', key),
|
||||
getUpdateState: () => ipcRenderer.invoke('get-update-state'),
|
||||
checkForUpdatesNow: () => ipcRenderer.invoke('check-for-updates-now'),
|
||||
checkForUpdates: () => ipcRenderer.send('check-for-updates'),
|
||||
downloadUpdate: () => ipcRenderer.send('download-update'),
|
||||
quitAndInstall: () => ipcRenderer.send('quit-and-install'),
|
||||
onUpdateState: (callback) => ipcRenderer.on('update-state', (event, state) => callback(state)),
|
||||
onUpdateAvailable: (callback) => ipcRenderer.on('update-available', (event, info) => callback(info)),
|
||||
onUpdateDownloaded: (callback) => ipcRenderer.on('update-downloaded', (event, info) => callback(info)),
|
||||
onUpdateError: (callback) => ipcRenderer.on('update-error', (event, error) => callback(error))
|
||||
onUpdateState: (callback) => onIpc('update-state', callback),
|
||||
onUpdateAvailable: (callback) => onIpc('update-available', callback),
|
||||
onUpdateDownloaded: (callback) => onIpc('update-downloaded', callback),
|
||||
onUpdateError: (callback) => onIpc('update-error', callback)
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue