forked from Vinci2/ElectronInstaller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
56 lines (44 loc) · 1.13 KB
/
main.js
File metadata and controls
56 lines (44 loc) · 1.13 KB
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
const {app, BrowserWindow, ipcMain, dialog} = require('electron')
let win;
const options = process.argv;
console.log('OPTIONS PASSED: ', process.argv);
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if(process.platform !== 'darwin') {
app.quit();
}
})
app.on('activate', function () {
if(win === null) {
createWindow();
}
})
ipcMain.on('openDialog', function() {
dialog.showOpenDialog(win, {
properties: ['openDirectory']
}).then(result => {
if(result.filePaths[0]) {
win.webContents.send('selectedPath', result.filePaths[0]);
}
})
})
ipcMain.on('closeApp', function () {
win.close()
} )
function createWindow() {
win = new BrowserWindow({
width: 600,
height: 600,
backgroundColor: '#fff',
webPreferences: {
nodeIntegration: true,
}
})
win.loadFile(`dist/electro-janusz/index.html`)
win.webContents.on('did-finish-load', () => {
win.webContents.send('passed-params', options.slice(2))
})
win.on('closed', function() {
win = null;
})
}