forked from mozilla/pdf.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
50 lines (43 loc) · 1.17 KB
/
main.js
File metadata and controls
50 lines (43 loc) · 1.17 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
const { app, BrowserWindow } = require("electron");
const path = require("path");
const { ipcMain } = require("electron");
function createWindow() {
const win = new BrowserWindow({
width: 1200,
height: 800,
frame: true,
icon: path.join(__dirname, 'assets', 'favicon-96x96.png'),
webPreferences: {
preload: path.join(__dirname, "preload.js"),
contextIsolation: true,
nodeIntegration: false
}
});
win.loadFile(path.join(__dirname, "web", "viewer.html"));
}
app.whenReady().then(() => {
createWindow();
});
let tray = null;
app.whenReady().then(() => {
tray = new Tray(path.join(__dirname, 'assets', 'tray-icon.png'));
const contextMenu = Menu.buildFromTemplate([
{ label: 'Kilépés', role: 'quit' }
]);
tray.setToolTip('VelPDF');
tray.setContextMenu(contextMenu);
});
ipcMain.on("minimize-window", (event) => {
BrowserWindow.getFocusedWindow().minimize();
});
ipcMain.on("maximize-window", (event) => {
const win = BrowserWindow.getFocusedWindow();
if (win.isMaximized()) {
win.unmaximize();
} else {
win.maximize();
}
});
ipcMain.on("close-window", (event) => {
BrowserWindow.getFocusedWindow().close();
});