This repository has been archived by the owner on Jul 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 133
/
Copy pathmain.js
131 lines (120 loc) · 4.07 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
const {app, BrowserWindow, Menu} = require('electron');
const isDevMode = require('electron-is-dev');
const path = require('path');
if (isDevMode) {
require('electron-reload')(__dirname + '/public');
}
let mainWindow;
function createWindow() {
const browserOptions = {
width: 800,
height: 600,
maximizeable: false,
icon: path.join(__dirname, '/public/img/logo.png')
};
mainWindow = new BrowserWindow(browserOptions);
mainWindow.loadURL('file://' + __dirname + '/app/index.html');
let template = [
{
label: 'YouTube To MP3',
submenu: [
{label: 'About Application', selector: 'orderFrontStandardAboutPanel:'},
{type: 'separator'},
{
label: 'Quit',
accelerator: 'Command+Q',
click: function() {
app.quit();
}
}
]
},
{
label: 'Edit',
submenu: [
{role: 'Reload', accelerator: 'CmdOrCtrl+R', selector: 'reload:'},
{label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:'},
{label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:'},
{type: 'separator'},
{label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:'},
{label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:'},
{label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:'}
]
},
{
label: 'Preferences',
submenu: [
{
label: 'Download Folder',
click: () => {
mainWindow.webContents.send('promptForChangeDownloadFolder');
}
},
{
label: 'Change Bitrate',
submenu: [
{
label: '320 (Full Quality)',
click: () => {
mainWindow.webContents.send('changeBitrate', 320);
}
},
{
label: '192 (High Quality)',
click: () => {
mainWindow.webContents.send('changeBitrate', 192);
}
},
{
label: '160 (CD Quality)',
click: () => {
mainWindow.webContents.send('changeBitrate', 160);
}
},
{
label: '130 (Radio Quality)',
click: () => {
mainWindow.webContents.send('changeBitrate', 130);
}
},
{
label: '65 (Minimal Quality)',
click: () => {
mainWindow.webContents.send('changeBitrate', 65);
}
}
]
}
]
}
];
// If developing add dev menu option to menu bar
if (isDevMode) {
template.push({
label: 'Dev Options',
submenu: [
{
label: 'Open Dev Tools',
click: () => {
mainWindow.webContents.openDevTools();
}
}
]
});
}
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
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();
}
});