-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
61 lines (47 loc) · 1.31 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
56
57
58
59
const electron = require('electron');
const ipcMain = electron.ipcMain;
const dailog = electron.dialog;
const app = electron.app
const BrowserWindow = electron.BrowserWindow
const path = require('path')
const url = require('url')
process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
let mainWindow
function createWindow () {
mainWindow = new BrowserWindow({width: 1400, height: 768,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
}
})
mainWindow.loadURL(`file://${__dirname}/index.html`);
mainWindow.webContents.openDevTools()
mainWindow.setMenu(null);
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
})
let dir;
ipcMain.on('selectDirectory', function(event, arg) {
dailog.showOpenDialog({properties: ['openDirectory'] }).then(function (response) {
if (!response.canceled) {
console.log(response.filePaths[0]);
dir = response.filePaths[0];
event.sender.send('variable-reply', dir);
} else {
console.log("no file selected");
}
});
});