-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
46 lines (40 loc) · 1.3 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
//const { updateElectronApp, UpdateSourceType } = require('update-electron-app')
//updateElectronApp()
const { app, BrowserWindow, dialog, ipcMain } = require('electron')
const path = require("path")
if (require('electron-squirrel-startup')) return app.quit();
let win
const createWindow = () => {
win = new BrowserWindow({
width: process.env.NODE_ENV === "development" ? 785 : 535,
height: 765,
frame: false,
resizable: true,
icon: __dirname + '/icons/512x512.png',
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
}
})
win.loadFile('ZplEscPrinter/main.html')
if(process.env.NODE_ENV === "development"){
win.webContents.openDevTools()
}
}
ipcMain.on('select-dirs', async (event, arg) => {
const result = await dialog.showOpenDialog(win, {
properties: ['openDirectory']
})
event.sender.send('selected-dirs', result.filePaths)
})
ipcMain.on('select-file', async (event, arg) => {
const result = await dialog.showOpenDialog(win, {
properties: ['openFile'],
filters: [{ name: 'Raw Print', extensions: ['raw'] }]
})
event.sender.send('selected-file', result.filePaths)
})
app.whenReady().then(() => {
createWindow()
})