-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
55 lines (45 loc) · 1.51 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
// Modules to control application life and create native browser window
const { app, BrowserWindow, ipcMain, shell, dialog, Menu } = require('electron')
const path = require("path");
const menu = Menu.buildFromTemplate([])
Menu.setApplicationMenu(menu)
let mainWindow
if (process.defaultApp) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('myori-thermal', process.execPath, [path.resolve(process.argv[1])])
}
} else {
app.setAsDefaultProtocolClient('myori-thermal')
}
const gotTheLock = app.requestSingleInstanceLock()
if (!gotTheLock) {
app.quit()
} else {
// Create mainWindow, load the rest of the app, etc...
app.whenReady().then(() => {
createWindow()
})
}
function createWindow() {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 300,
height: 300,
icon: path.join(__dirname, "assets/myorilogo.png"),
webPreferences: {
preload: path.join(__dirname, "preload.js"),
nodeIntegration: true, // ATENÇÃO AQUI - attention here - that's why your node_module works or not
},
});
mainWindow.setResizable(false)
// and load the index.html of the app.
mainWindow.loadFile("index.html");
// Open the DevTools.
// mainWindow.webContents.openDevTools()
}
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on("window-all-closed", function () {
if (process.platform !== "darwin") app.quit();
});