-
Notifications
You must be signed in to change notification settings - Fork 0
/
preload.js
30 lines (24 loc) · 1.28 KB
/
preload.js
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
29
30
const { contextBridge, ipcRenderer } = require('electron/renderer');
contextBridge.exposeInMainWorld('versions', {
node: () => process.versions.node,
chrome: () => process.versions.chrome,
electron: () => process.versions.electron,
ping: () => ipcRenderer.invoke('ping')
})
contextBridge.exposeInMainWorld('main', {
openAboutPanel: (data) => ipcRenderer.invoke('openAboutPanel', data),
})
contextBridge.exposeInMainWorld('events', {
handleJournalEvent: (callback) => ipcRenderer.on('journal-event', callback),
handleJournalShutdown: (callback) => ipcRenderer.on('journal-event-Shutdown', callback),
handleJournalDocked: (callback) => ipcRenderer.on('journal-event-Docked', callback),
handleJournalUndocked: (callback) => ipcRenderer.on('journal-event-Undocked', callback),
handleJournalMusic: (callback) => ipcRenderer.on('journal-event-Music', callback),
})
contextBridge.exposeInMainWorld('settings', {
setInaraApiKey: (data) => {ipcRenderer.invoke('setInaraApiKey', data)},
getInaraApiKey: () => {return ipcRenderer.invoke('getInaraApiKey')},
setHideToTray: (data) => ipcRenderer.invoke('setHideToTray', data),
getHideToTray: () => {return ipcRenderer.invoke('getHideToTray')}
})
ipcRenderer.on('test', (_event, data) => console.log(data));