Skip to content

Commit 612a69d

Browse files
committed
Electron fixes
1 parent 658ee30 commit 612a69d

File tree

1 file changed

+32
-24
lines changed

1 file changed

+32
-24
lines changed

electron/main.js

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ const isDev = require('electron-is-dev');
66
let BASE_URL = `file://${__dirname}/app/index.html`;
77
let SCHEME = 'blockphotosapp';
88
if (isDev) {
9-
// BASE_URL = 'http://localhost:9876';
10-
9+
// BASE_URL = 'http://localhost:9876';
1110
}
1211

1312
protocol.registerStandardSchemes([SCHEME]);
@@ -26,29 +25,38 @@ if (!gotTheLock) {
2625
} else {
2726
app.on('second-instance', (event, commandLine) => {
2827
if (mainWindow && commandLine[1]) {
29-
if (mainWindow.isMinimized()) {
30-
mainWindow.restore();
31-
}
28+
if (mainWindow.isMinimized()) {
29+
mainWindow.restore();
30+
}
31+
32+
mainWindow.close();
33+
34+
mainWindow = new BrowserWindow({
35+
width: 500,
36+
height: 810,
37+
icon: path.join(__dirname, 'icons/png/64x64.png')
38+
});
3239

33-
var request = commandLine[1].split(":");
40+
var request = commandLine[1].split(':');
3441

35-
if (request[1] && currentAuthResponse !== request[1]) {
36-
currentAuthResponse = request[1];
42+
if (request[1] && currentAuthResponse !== request[1]) {
43+
currentAuthResponse = request[1];
3744

38-
mainWindow.focus();
39-
mainWindow.loadURL(BASE_URL + '?authResponse=' + request[1]);
40-
return true;
41-
}
45+
mainWindow.focus();
46+
mainWindow.loadURL(BASE_URL + '?authResponse=' + request[1]);
47+
return true;
48+
}
4249
}
4350
dialog.showMessageBox({
44-
message: "Authentication failed, please try again!",
45-
buttons: ["OK"]
51+
message: 'Authentication failed, please try again!',
52+
buttons: ['OK']
4653
});
4754
});
4855
}
4956

5057
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
51-
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
58+
if (require('electron-squirrel-startup')) {
59+
// eslint-disable-line global-require
5260
app.quit();
5361
}
5462

@@ -81,31 +89,31 @@ const createWindow = () => {
8189
app.on('ready', createWindow);
8290

8391
// Quit when all windows are closed.
84-
app.on('window-all-closed', function () {
92+
app.on('window-all-closed', function() {
8593
// On OS X it is common for applications and their menu bar
8694
// to stay active until the user quits explicitly with Cmd + Q
8795
if (process.platform !== 'darwin') {
8896
app.quit();
8997
}
90-
})
98+
});
9199

92-
app.on('activate', function () {
100+
app.on('activate', function() {
93101
// On OS X it's common to re-create a window in the app when the
94102
// dock icon is clicked and there are no other windows open.
95103
if (mainWindow === null) {
96104
createWindow();
97105
}
98-
})
106+
});
99107

100-
app.on('open-url', function (event, url) {
108+
app.on('open-url', function(event, url) {
101109
// On OS X it's common to re-create a window in the app when the
102110
// dock icon is clicked and there are no other windows open.
103111
if (mainWindow) {
104112
if (mainWindow.isMinimized()) {
105113
mainWindow.restore();
106114
}
107115

108-
var request = url.split(":");
116+
var request = url.split(':');
109117

110118
if (request[1] && currentAuthResponse !== request[1]) {
111119
currentAuthResponse = request[1];
@@ -116,10 +124,10 @@ app.on('open-url', function (event, url) {
116124
}
117125
}
118126
dialog.showMessageBox({
119-
message: "Authentication failed, please try again!",
120-
buttons: ["OK"]
127+
message: 'Authentication failed, please try again!',
128+
buttons: ['OK']
121129
});
122-
})
130+
});
123131

124132
// In this file you can include the rest of your app's specific main process
125133
// code. You can also put them in separate files and require them here.

0 commit comments

Comments
 (0)