mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-14 15:11:24 +00:00
Compatiable with latest electron
This commit is contained in:
56
main.js
56
main.js
@@ -20,20 +20,42 @@ crashReporter.start({
|
|||||||
// be closed automatically when the javascript object is GCed.
|
// be closed automatically when the javascript object is GCed.
|
||||||
var mainWindow = null;
|
var mainWindow = null;
|
||||||
|
|
||||||
// single instance
|
if (!app.makeSingleInstance) {
|
||||||
const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
|
app.allowRendererProcessReuse = true
|
||||||
// Someone tried to run a second instance, we should focus our window.
|
|
||||||
if (mainWindow) {
|
|
||||||
mainWindow.show();
|
|
||||||
if (mainWindow.isMinimized()) {
|
|
||||||
mainWindow.restore();
|
|
||||||
}
|
|
||||||
mainWindow.focus();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (shouldQuit) {
|
// single instance
|
||||||
app.quit()
|
const gotTheLock = app.requestSingleInstanceLock()
|
||||||
|
if (!gotTheLock) {
|
||||||
|
console.log("gotTheLock is false, another instance is running")
|
||||||
|
app.quit()
|
||||||
|
} else {
|
||||||
|
app.on('second-instance', (event, commandLine, workingDirectory) => {
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.show();
|
||||||
|
if (mainWindow.isMinimized()) {
|
||||||
|
mainWindow.restore();
|
||||||
|
}
|
||||||
|
mainWindow.focus();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// single instance
|
||||||
|
const shouldQuit = app.makeSingleInstance((commandLine, workingDirectory) => {
|
||||||
|
// Someone tried to run a second instance, we should focus our window.
|
||||||
|
if (mainWindow) {
|
||||||
|
mainWindow.show();
|
||||||
|
if (mainWindow.isMinimized()) {
|
||||||
|
mainWindow.restore();
|
||||||
|
}
|
||||||
|
mainWindow.focus();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (shouldQuit) {
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quit when all windows are closed.
|
// Quit when all windows are closed.
|
||||||
@@ -181,7 +203,10 @@ function openIt() {
|
|||||||
width: 1050,
|
width: 1050,
|
||||||
height: 595,
|
height: 595,
|
||||||
frame: process.platform != 'darwin',
|
frame: process.platform != 'darwin',
|
||||||
transparent: false
|
transparent: false,
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -207,6 +232,9 @@ function openIt() {
|
|||||||
ipc.on('openUrl', function(event, arg) {
|
ipc.on('openUrl', function(event, arg) {
|
||||||
console.log('openUrl', arg);
|
console.log('openUrl', arg);
|
||||||
|
|
||||||
|
arg.webPreferences = arg.webPreferences === undefined ? {} : arg.webPreferences;
|
||||||
|
arg.webPreferences.nodeIntegration = true;
|
||||||
|
|
||||||
var html = arg.html;
|
var html = arg.html;
|
||||||
var everWindow = mainWindow;
|
var everWindow = mainWindow;
|
||||||
var win2 = new BrowserWindow(arg);
|
var win2 = new BrowserWindow(arg);
|
||||||
|
Reference in New Issue
Block a user