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