-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
61 lines (56 loc) · 1.62 KB
/
main.js
File metadata and controls
61 lines (56 loc) · 1.62 KB
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
const { app, BrowserWindow, BrowserView } = require('electron');
let popup = null;
function afterStartup(e, content){
if(content.getType()=='webview'){
content.on('new-window', function(e, url){
e.preventDefault();
if(popup==null){
popup = new BrowserWindow({
width: 1100,
height: 800
});
popup.on('closed', function(){ popup = null;})
}
popup.loadURL(url);
popup.focus();
});
content.on("dom-ready", function(e){
content.insertCSS(
"::-webkit-scrollbar {width: 3px !important; background: transparent !important;}\n::-webkit-scrollbar-thumb {background-color: #888888 !important;} "
);
});
}
}
function createWindow() {
let browserWindow = new BrowserWindow(
{
icon: 'build/icon.ico',
fullscreen: false,
show: false,
webPreferences:
{
devTools: true,
webviewTag: true
}
}
);
browserWindow.maximize();
browserWindow.setResizable(false);
let pos = {
x: 100,
y: 0
};
browserWindow.webContents.loadFile("content.html");
browserWindow.on('closed', function () {
if(popup!=null){
popup.close();
popup=null;
}
browserWindow = null;
});
browserWindow.once('ready-to-show', function () {
browserWindow.show();
});
}
app.on('ready', createWindow);
app.on('web-contents-created', afterStartup);