Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createWindow() {
log.info('Starting');
if (template.length) {
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
}
if (process.env.NODE_ENV === 'production') {
log.info('Starting updater..');
autoUpdater
.checkForUpdates()
.then(() => {
log.info('Promise fulfilled');
})
.catch(reason => {
log.info(`Handle rejected promise (${reason.stack || reason}) here.`);
});
}
log.info('Creating browser window');
// Create the browser window.
// Monospace font size set from config file
//defaultMonospaceFontSize: 14,
// Make sure that requestAnimationFrame still runs even when
// window is minimized, as it is used to trigger updates
// to device output panel
backgroundThrottling: false,
// Needed for CSS 'grid' support
experimentalFeatures: true
}
})
// Create the main application menu
Menu.setApplicationMenu(VBMenu.createAppMenu())
// Display the Developer Tools (not in production release)
//global.mainWindow.webContents.openDevTools()
// Load the app's index.html file from disk
global.mainWindow.loadURL(`file://${__dirname}/index.html`)
// The 'resize' event is emitted when the window's dimensions are changed
global.mainWindow.on('resize', () => {
if (!global.mainWindow.isMaximized()) {
[config.width, config.height] = global.mainWindow.getSize()
}
})
// The 'move' event is emitted when the window is repositioned
global.mainWindow.on('move', () => {
app.on('ready', () => {
// Restore last windows
config.get('windowStates').forEach((state, index) => createWindow(windows, index, state))
// If there wasn't any windows, create a new one
if (windows.length === 0) createWindow(windows, 0)
// Create and attach Menu
Menu.setApplicationMenu(createAppMenu(windows))
// If in production, initialize auto updater
if (process.env.NODE_ENV !== 'development') initializeAutoUpdater()
})
app.injectMenu = function (menu) {
try {
Menu.setApplicationMenu(Menu.buildFromTemplate(menu))
} catch (err) {
console.warn('Cannot inject menu.')
}
}
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
{ label: "Select All", accelerator: "CmdOrCtrl+A", selector: "selectAll:" },
{
label: "Dev tools",
accelerator: "CmdOrCtrl+J",
click() {
mainWindow.webContents.openDevTools();
}
}
]
}
];
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
}
controlStyle = null;
break;
case 'windows_nt':
controlStyle = 'Windows';
break;
default:
controlStyle = 'Linux';
break;
}
if (osType.includes('windows')) {
controlStyle = 'Windows';
}
}
global.controlsStyle = controlStyle;
if (osType === 'darwin') {
Menu.setApplicationMenu(
Menu.buildFromTemplate([
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' },
{ role: 'pasteandmatchstyle' },
{ role: 'delete' },
{ role: 'selectall' },
],
},
]),
const win = windowProvider.getWindow();
const menuVisible = win.isMenuBarVisible();
win.autoHideMenuBar = menuVisible;
win.setMenuBarVisibility(!menuVisible);
browserviewPreparer.setBounds(win, windowProvider.getBrowserView());
},
label: "Toggle Menu Bar Visibility",
});
}
const window = windowProvider.getWindow();
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
window.autoHideMenuBar = true;
window.setMenuBarVisibility(false);
browserviewPreparer.setBounds(window, windowProvider.getBrowserView());
}
width: mainScreen.size.width,
height: mainScreen.size.height,
title: "POCKETNET v" + app.getVersion(),
webSecurity : false,
icon: defaultIcon,
});
win.maximize();
let isHidden = process.argv.find(function(el) { return el == '--hidden'; })
if (isHidden) {
win.hide();
}
Menu.setApplicationMenu(null)
win.loadFile('index_el.html')
electronLocalshortcut.register(win, 'CommandOrControl+Shift+I', () => {
win.webContents.toggleDevTools()
});
win.webContents.on('new-window', function(event, url) {
event.preventDefault();
open(url);
});
win.on('close', function(e) {
if (!willquit) {
e.preventDefault();
win.hide();
export default function () {
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
}
autoUpdater.on('update-available', (info) => {
const updateAvailibleMenu = {
label: "New update availible",
submenu: [{
label: "release info",
click: () => { require('electron').shell.openExternal('https://github.com/Almenon/AREPL/releases') }
}]
}
menuTemplate.push(updateAvailibleMenu)
Menu.setApplicationMenu(Menu.buildFromTemplate(menuTemplate))
})
autoUpdater.on('update-not-available', (info) => {