Show window on second launch
This commit is contained in:
13
electron.js
13
electron.js
@@ -14,6 +14,7 @@ const AutoLaunch = require('auto-launch');
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
let mainContextWindow;
|
||||
let mainWindow;
|
||||
let mainWindowTray;
|
||||
let mountedPIDs = [];
|
||||
@@ -53,7 +54,7 @@ function createWindow() {
|
||||
});
|
||||
|
||||
const image = nativeImage.createFromPath(path.join(__dirname, '/build/icon.ico'));
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
mainContextWindow = Menu.buildFromTemplate([
|
||||
{
|
||||
label: 'Visible', type: 'checkbox', click(item) {
|
||||
if (item.checked) {
|
||||
@@ -78,14 +79,14 @@ function createWindow() {
|
||||
}
|
||||
]);
|
||||
|
||||
contextMenu.items[0].checked = true;
|
||||
mainContextWindow.items[0].checked = true;
|
||||
autoLauncher.isEnabled()
|
||||
.then((enabled) => {
|
||||
contextMenu.items[1].checked = enabled;
|
||||
mainContextWindow.items[1].checked = enabled;
|
||||
|
||||
mainWindowTray = new Tray(image);
|
||||
mainWindowTray.setToolTip('Repertory UI');
|
||||
mainWindowTray.setContextMenu(contextMenu)
|
||||
mainWindowTray.setContextMenu(mainContextWindow)
|
||||
})
|
||||
.catch(() => {
|
||||
app.quit();
|
||||
@@ -99,6 +100,10 @@ if (!instanceLock) {
|
||||
} else {
|
||||
app.on('second-instance', () => {
|
||||
if (mainWindow) {
|
||||
mainWindow.show();
|
||||
if (mainContextWindow) {
|
||||
mainContextWindow.items[0].checked = true;
|
||||
}
|
||||
if (mainWindow.isMinimized()) {
|
||||
mainWindow.restore();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user