-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.js
77 lines (62 loc) · 1.8 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const electron = require('electron');
const url = require('url');
const path = require('path');
const ipcMain = require('electron').ipcMain;
const {app, BrowserWindow, dialog, Menu} = electron;
let mainWindow;
app.on('ready', function(){
mainWindow = new BrowserWindow({webPreferences:
{
nodeIntegration: true,
},
frame:false, //https://github.com/binaryfunt/electron-seamless-titlebar-tutorial
icon: "web/favicons/loaderlogo.png",
});
mainWindow.loadURL('http://localhost:8000/index.html');
});
/* OPEN FILE */
ipcMain.on('openFile',(event,arg)=>{
if(arg===true){
const files = dialog.showOpenDialogSync(mainWindow,{
properties: ['openFile'],
filters: [{name:'Audio', extensions:['mp3','ogg','wav','aac']}]
});
if(!files) return;
const file = files[0];
event.sender.send('filepathname',file);
}
});
/* GET EXPORT DIRECTORY */
ipcMain.on('exportDirectory',(event,arg)=>{
if(arg===true){
const directories = dialog.showOpenDialogSync(mainWindow,{
properties: ['openDirectory'],
});
if(!directories) return;
const directory = directories[0];
event.sender.send('directorypath',directory);
}
});
/* HANDLING WINDOW EVENTS*/
ipcMain.on('winmaximise',(event,arg)=>{
if(arg===true){
mainWindow.maximize();
event.sender.send('toggleMaxRestoreButtons',true);
}
});
ipcMain.on('winminimise',(event,arg)=>{
if(arg===true){
mainWindow.minimize();
}
});
ipcMain.on('winclose',(event,arg)=>{
if(arg===true){
mainWindow.close();
}
});
ipcMain.on('winrestore',(event,arg)=>{
if(arg===true){
mainWindow.unmaximize();
event.sender.send('toggleMaxRestoreButtons',false);
}
});