This repository has been archived by the owner on Sep 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
105 lines (90 loc) · 2.29 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
const { app, BrowserWindow } = require('electron');
const path = require('path');
const shell = require('electron').shell;
let isShown = true;
require('@electron/remote/main').initialize()
require('electron').protocol.registerSchemesAsPrivileged([
{ scheme: 'js', privileges: { standard: true, secure: true } }
]);
app.win = null;
app.on('ready', () => {
app.win = new BrowserWindow({
width: 312,
height: 720,
minWidth: 312,
minHeight: 320,
resizable: true,
backgroundColor: '#000000',
frame: process.platform !== 'darwin',
utoHideMenuBar: process.platform === 'darwin',
skipTaskbar: process.platform === 'darwin',
icon: path.join(
__dirname,
{
darwin: 'icon.icns',
linux: 'icon.png',
win32: 'icon.ico'
}[process.platform] || 'icon.ico'
),
icon: 'icon.png',
webPreferences: {
zoomFactor: 1.0,
nodeIntegration: true,
enableRemoteModule: true,
contextIsolation: false,
backgroundThrottling: false,
}
});
require("@electron/remote/main").enable(app.win.webContents);
// app.win.loadURL(path.join(__dirname, 'public', 'index.html'));
app.win.loadFile(`public/index.html`);
app.win.on('closed', () => {
win = null;
app.quit();
});
app.on('window-all-closed', () => {
app.quit();
});
app.on('activate', () => {
if (app.win === null) {
createWindow();
} else {
app.win.show();
}
});
app.win.webContents.on('will-navigate', (event, url) => {
event.preventDefault();
shell.openExternal(url);
});
});
app.inspect = function () {
app.win.toggleDevTools();
};
app.toggleMenubar = function () {
app.win.setMenuBarVisibility(!app.win.isMenuBarVisible());
};
app.toggleFullscreen = function () {
app.win.setFullScreen(!app.win.isFullScreen());
};
app.toggleVisible = function () {
if (process.platform === 'darwin') {
if (isShown && !app.win.isFullScreen()) {
app.win.hide();
} else {
app.win.show();
}
} else {
if (!app.win.isMinimized()) {
app.win.minimize();
} else {
app.win.restore();
}
}
};
// app.injectMenu = function(menu) {
// try {
// Menu.setApplicationMenu(Menu.buildFromTemplate(menu));
// } catch (err) {
// console.warn('Cannot inject menu.');
// }
// };