-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
57 lines (48 loc) · 1.38 KB
/
main.js
File metadata and controls
57 lines (48 loc) · 1.38 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
57
const { app, BrowserWindow, dialog, ipcMain } = require('electron');
const fs = require('fs');
let mainWindow;
let paths;
function createWindow() {
mainWindow = new BrowserWindow({
width: 1000,
height: 800,
webPreferences: { nodeIntegration: true },
});
mainWindow.maximize();
mainWindow.loadFile('index.html');
ipcMain.on('getPaths', event => {
dialog
.showOpenDialog(mainWindow, {
buttonLabel: 'Select paths text file',
defaultPath: app.getAppPath(),
})
.then(result => {
paths = result.filePaths;
event.reply('getPaths', result.filePaths);
})
.catch(err => {
console.log(err);
});
});
mainWindow.on('close', function (e) {
const choice = dialog.showMessageBoxSync(this, {
type: 'question',
buttons: ['Yes', 'No'],
title: 'Confirm',
message: 'Are you sure you want to quit?',
});
if (choice === 1) {
e.preventDefault();
}
});
mainWindow.on('closed', () => {
mainWindow = null;
});
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
app.on('activate', () => {
if (mainWindow === null) createWindow();
});