Skip to content
This repository was archived by the owner on Jan 14, 2022. It is now read-only.

Commit 36da556

Browse files
committed
updated dependencies
1 parent be88fd5 commit 36da556

File tree

6 files changed

+690
-295
lines changed

6 files changed

+690
-295
lines changed

app/app-main.js

Lines changed: 45 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,51 @@
1-
const { app, Menu, ipcMain } = require('electron')
1+
const { app, Menu, ipcMain } = require("electron");
22

3-
let mainWindow = null
3+
let mainWindow = null;
44

5-
const isSecondInstance = app.makeSingleInstance(function (
6-
commandLine,
7-
workingDirectory
8-
) {
9-
if (mainWindow) {
10-
if (process.platform === 'win32') {
11-
mainWindow.minimize()
12-
mainWindow.restore()
13-
}
14-
mainWindow.show()
15-
mainWindow.focus()
16-
}
17-
return true
18-
})
5+
const gotTheLock = app.requestSingleInstanceLock();
196

20-
if (isSecondInstance) {
21-
app.exit()
22-
}
7+
if (!gotTheLock) {
8+
app.quit();
9+
} else {
10+
app.on("second-instance", (event, commandLine, workingDirectory) => {
11+
if (mainWindow) {
12+
if (process.platform === "win32") {
13+
mainWindow.minimize();
14+
mainWindow.restore();
15+
}
16+
mainWindow.show();
17+
mainWindow.focus();
18+
}
19+
});
2320

24-
app.on('ready', () => {
25-
mainWindow = require('./app-window')(app)
26-
require('./app-tray')(app, mainWindow)
27-
ipcMain.on('bringToFront', () => {
28-
if (process.platform === 'win32') {
29-
mainWindow.minimize()
30-
mainWindow.restore()
21+
app.on("ready", () => {
22+
mainWindow = require("./app-window")(app);
23+
require("./app-tray")(app, mainWindow);
24+
ipcMain.on("bringToFront", () => {
25+
if (process.platform === "win32") {
26+
mainWindow.minimize();
27+
mainWindow.restore();
28+
}
29+
mainWindow.show();
30+
mainWindow.focus();
31+
});
32+
const template = require("./app-menu")(app, mainWindow);
33+
const menu = Menu.buildFromTemplate(template);
34+
switch (process.platform) {
35+
case "darwin":
36+
Menu.setApplicationMenu(menu);
37+
break;
38+
case "win32":
39+
mainWindow.setMenu(menu);
40+
break;
41+
case "linux":
42+
Menu.setApplicationMenu(menu);
43+
mainWindow.setMenu(menu);
44+
break;
3145
}
32-
mainWindow.show()
33-
mainWindow.focus()
34-
})
35-
const template = require('./app-menu')(app, mainWindow)
36-
const menu = Menu.buildFromTemplate(template)
37-
switch (process.platform) {
38-
case 'darwin':
39-
Menu.setApplicationMenu(menu)
40-
break
41-
case 'win32':
42-
mainWindow.setMenu(menu)
43-
break
44-
case 'linux':
45-
Menu.setApplicationMenu(menu)
46-
mainWindow.setMenu(menu)
47-
break
48-
}
49-
})
46+
});
5047

51-
app.on('before-quit', () => {
52-
mainWindow.shouldQuit()
53-
})
48+
app.on("before-quit", () => {
49+
mainWindow.shouldQuit();
50+
});
51+
}

app/app-window.js

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
const electron = require('electron')
2-
const BrowserWindow = electron.BrowserWindow
3-
const path = require('path')
4-
const Store = require('electron-store')
5-
const store = new Store()
6-
const _ = require('lodash')
1+
const electron = require("electron");
2+
const BrowserWindow = electron.BrowserWindow;
3+
const path = require("path");
4+
const Store = require("electron-store");
5+
const store = new Store();
6+
const _ = require("lodash");
77

8-
const showMenu = process.platform !== 'win32'
9-
const windowSize = store.get('windowsize') || { width: 1080, height: 720 }
10-
let mainWindow = null
11-
let isQuitting = false
8+
const showMenu = process.platform !== "win32";
9+
const windowSize = store.get("windowsize") || { width: 1080, height: 720 };
10+
let mainWindow = null;
11+
let isQuitting = false;
1212

13-
function createWindow (app) {
13+
function createWindow(app) {
1414
mainWindow = new BrowserWindow({
1515
width: windowSize.width,
1616
height: windowSize.height,
@@ -19,49 +19,50 @@ function createWindow (app) {
1919
autoHideMenuBar: showMenu,
2020
webPreferences: {
2121
zoomFactor: 1.0,
22-
blinkFeatures: 'OverlayScrollbars'
22+
nodeIntegration: true,
23+
blinkFeatures: "OverlayScrollbars"
2324
},
24-
icon: path.resolve(__dirname, '../resources/icon/icon512.png')
25-
})
25+
icon: path.resolve(__dirname, "../resources/icon/icon512.png")
26+
});
2627

27-
const url = 'file://' + path.resolve(__dirname, './index.html')
28+
const url = "file://" + path.resolve(__dirname, "./index.html");
2829

29-
mainWindow.loadURL(url)
30-
mainWindow.on('resize', _.throttle(storeWindowSize, 500))
31-
if (process.env.NODE_ENV === 'dev') {
32-
mainWindow.webContents.openDevTools()
30+
mainWindow.loadURL(url);
31+
mainWindow.on("resize", _.throttle(storeWindowSize, 500));
32+
if (process.env.NODE_ENV === "dev") {
33+
mainWindow.webContents.openDevTools();
3334
}
34-
const screen = electron.screen.getPrimaryDisplay()
35+
const screen = electron.screen.getPrimaryDisplay();
3536
if (
3637
windowSize.width >= screen.size.width &&
3738
windowSize.height >= screen.size.height - 1
3839
) {
39-
mainWindow.maximize()
40+
mainWindow.maximize();
4041
}
4142
// prevent the app from quitting
42-
mainWindow.on('close', e => {
43+
mainWindow.on("close", e => {
4344
if (!isQuitting) {
44-
e.preventDefault()
45-
mainWindow.blur()
46-
if (process.platform === 'darwin') {
47-
app.hide()
45+
e.preventDefault();
46+
mainWindow.blur();
47+
if (process.platform === "darwin") {
48+
app.hide();
4849
} else {
49-
mainWindow.hide()
50+
mainWindow.hide();
5051
}
5152
}
52-
})
53+
});
5354

54-
mainWindow.shouldQuit = function () {
55-
isQuitting = true
56-
}
55+
mainWindow.shouldQuit = function() {
56+
isQuitting = true;
57+
};
5758

58-
return mainWindow
59+
return mainWindow;
5960
}
6061

61-
function storeWindowSize () {
62+
function storeWindowSize() {
6263
try {
63-
store.set('windowsize', mainWindow.getBounds())
64+
store.set("windowsize", mainWindow.getBounds());
6465
} catch (e) {}
6566
}
6667

67-
module.exports = createWindow
68+
module.exports = createWindow;

app/index.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
</script>
1919
<script type='text/javascript'>
2020
const electron = require('electron')
21-
electron.webFrame.setZoomLevelLimits(1, 1)
2221
var scriptUrl = window._.find(electron.remote.process.argv, (a) => a === '--hot')
2322
? 'http://localhost:8000/assets/main.js'
2423
: '../compiled/main.js'
@@ -29,4 +28,4 @@
2928
</script>
3029
</body>
3130

32-
</html>
31+
</html>

0 commit comments

Comments
 (0)