-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
49 lines (39 loc) · 1022 Bytes
/
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
const { create } = require('domain')
const { app, dialog, BrowserWindow, ipcMain, NodeEventEmitter } = require('electron')
let windows = new Set()
function createWindow () {
const newWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
})
windows.add(newWindow)
newWindow.loadFile('index.html')
}
app.whenReady().then(createWindow)
app.on('window-all-closed', () => {
app.quit()
})
app.on('activate', () => {
if(BrowserWindow.getAllWindows().length === 0) {
createWindow()
}
})
let file = ""
app.on('open-file', (event, arg) => {
file = arg
if(windows.size !== 0)
createWindow()
})
ipcMain.on('query-save-location', (event, arg) => {
event.returnValue = dialog.showSaveDialogSync({defaultPath: arg + ".mch"})
})
ipcMain.on('query-open-location', (event, _) => {
event.returnValue = dialog.showOpenDialogSync({properties: ['openFile']})
})
ipcMain.on('query-open-with', (event, _) => {
event.returnValue = file
})