-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
56 lines (44 loc) · 1.31 KB
/
app.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
const electron = require('electron');
const MCEngine = require("./api/metadatacleaner/mcengine");
const RouteMenu = require("./routes/menu/mainMenu");
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
const ipc = electron.ipcMain;
const menu = electron.Menu;
let mainWindow;
function createWindow () {
mainWindow = new BrowserWindow({width: 800, height: 600});
mainWindow.loadURL('file://'+__dirname+'/views/index.html');
mainWindow.on('closed', () => {
mainWindow = null;
});
menu.setApplicationMenu(RouteMenu.getMenu(mainWindow));
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (mainWindow === null) {
createWindow();
}
});
// Start cleaning process
ipc.on('clean', (event, arg) => {
MCEngine.processCleaning(event, arg.filepath);
});
// Stop cleaning process
ipc.on('stop', (event, arg) => {
MCEngine.stopProcess(event, arg.filepath);
});
// Save settings then go home
ipc.on('confirm_parameter', (event, arg) => {
MCEngine.saveSettings(arg.data);
mainWindow.loadURL('file://'+__dirname+'/views/index.html');
});
// Cancel settings then go home
ipc.on('cancel_parameter', (event, arg) => {
mainWindow.loadURL('file://'+__dirname+'/views/index.html');
});