-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
59 lines (50 loc) · 1.75 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const { app, BrowserWindow, Menu } = require("electron");
const path = require("path");
app.disableHardwareAcceleration(); // for integrated Intel GPU
Menu.setApplicationMenu(false);
function createWindow() {
const mainWindow = new BrowserWindow({
width: 960,
height: 980,
minWidth: 860,
minHeight: 880,
backgroundColor: "#000000",
resizable: true,
icon: __dirname + "/camera.ico",
webPreferences: {
contextIsolation: false,
nodeIntegration: true,
nodeIntegrationInWorker: true,
sandbox: false, //https://www.electronjs.org/blog/electron-20-0
preload: path.join(__dirname, "app.js"),
},
});
// mainWindow.loadURL('http://localhost:3000');
mainWindow.loadFile(path.join(__dirname, "start.html"));
// mainWindow.openDevTools();
}
let myWindow = null;
const gotTheLock = app.requestSingleInstanceLock();
if (!gotTheLock) {
app.quit();
} else {
app.on("second-instance", (event, commandLine, workingDirectory) => {
// Someone tried to run a second instance, we should focus our window.
if (myWindow) {
if (myWindow.isMinimized()) myWindow.restore();
myWindow.focus();
}
});
// Create myWindow, load the rest of the app, etc...
app.whenReady().then(() => {
myWindow = createWindow();
app.on("activate", function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
}
app.on("window-all-closed", function () {
if (process.platform !== "darwin") app.quit();
});
// run with electron: npm start
// build using electron-packager: npx electron-packager . --overwrite --asar --ignore=.gitignore --ignore=.+.lnk --ignore=.+.code-workspace --ignore=.+.bat --ignore=.gitattributes --ignore=^/art --ignore=^/test --icon='./camera.ico'