-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
61 lines (51 loc) · 1.38 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
const {app, BrowserWindow} = require('electron');
const path = require('path');
const url = require('url');
require('electron-context-menu')({
prepend: (params, browserWindow) => [{
label: 'Save image not working',
// Only show it when right-clicking images
visible: params.mediaType === 'image'
}]
});
require('electron-dl')();
// init win
let win;
function createWindow() {
// Create browser window
win = new BrowserWindow({
width:800,
height:600,
icon:__dirname+'/img/youtubepcappicon.png',
autoHideMenuBar: true,
frame: false,
webPreferences: {
webviewTag: true,
nodeIntegration: true ,
enableRemoteModule: true,
contextIsolation: false
}
})
// Load index.html
win.loadURL('file://' + __dirname + '/index.html');
win.maximize();
//win.webContents.openDevTools()
win.on('closed', () => {
win = null;
});
win.webContents.on('new-window', (event, url) => {
event.preventDefault()
win = new BrowserWindow({show: false,autoHideMenuBar: true})
win.once('ready-to-show', () => win.show())
win.loadURL(url)
event.newGuest = win
});
};
// Run create window function
app.on('ready', createWindow);
// Quit when all windows are closed
app.on('window-all-closed', () => {
if(process.platform !== 'darwin'){
app.quit();
}
});