electron launcher
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 lines
1.0 KiB

// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
const {ipcRenderer} = require('electron')
window.api = [
"showSuspensionWindow",
"resizeWindow",
"setUnReadMessage",
"getUnReadMessage",
"windowMoveHandle",
"exitSystem",
"openDevTools",
"hideMainWindow",
"showMainWindow",
"minimize",
"hideSuspensionWindow"
].reduce((acc, apiName) => {
acc[apiName] = (...params) => {
return ipcRenderer.send(apiName, ...params)
}
return acc
}, {
on: ipcRenderer.on.bind(ipcRenderer),
removeListener: ipcRenderer.removeListener.bind(ipcRenderer)
});
ipcRenderer.on('getUnReadMessage', (e, args) => {
window.getUnReadMessage(args[0]);
});
window.addEventListener("keydown", e => {
const {altKey, ctrlKey, keyCode} = e;
if (altKey && ctrlKey && keyCode === 70) {
const currentWindow = require('electron').remote.getCurrentWindow();
currentWindow && currentWindow.toggleDevTools();
e.preventDefault();
}
})