-
Notifications
You must be signed in to change notification settings - Fork 0
/
preload.js
29 lines (23 loc) · 887 Bytes
/
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
const {store} = require('./store');
const { contextBridge } = require('electron')
// Port over some config functions without giving the iframe the whole of Electron/Your PC to play with.
// See https://www.electronjs.org/docs/tutorial/context-isolation and https://www.electronjs.org/docs/tutorial/security
contextBridge.exposeInMainWorld('neutron', {
store_get: (param) => {
if (!param) {
return store.store
}
return store.get(param)
},
store_set: (param, value) => {return store.set(param,value)},
store_clear: () => {store.clear()}
})
window.addEventListener('DOMContentLoaded', () => {
const replaceText = (selector, text) => {
const element = document.getElementById(selector)
if (element) element.innerText = text
}
for (const type of ['chrome', 'node', 'electron']) {
replaceText(`${type}-version`, process.versions[type])
}
})