-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.js
executable file
·129 lines (113 loc) · 3.31 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
const { app, shell, BrowserWindow, Menu, nativeImage } = require("electron");
const windowStateKeeper = require("electron-window-state");
const path = require("path");
let mainWindow = null;
if (process.argv.indexOf("-dev") > -1) global.dev = true;
app.allowRendererProcessReuse = false;
function createWindow() {
let mainWindowState = windowStateKeeper({
defaultWidth: 1200,
defaultHeight: 700,
});
mainWindow = new BrowserWindow({
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
minWidth: 1200,
minHeight: 700,
maximizable: process.platform === "win32",
title: "Flixerr",
backgroundColor: "#FFF",
titleBarStyle: "hiddenInset",
show: false,
defaultEncoding: "utf8",
webPreferences: {
nodeIntegration: true,
enableRemoteModule: true,
},
});
const icon = nativeImage.createFromPath(__dirname + "/assets/img/icon.ico");
mainWindow.setIcon(icon);
mainWindow.webContents.session.webRequest.onHeadersReceived(
(details, callback) => {
if (details.responseHeaders["x-frame-options"]) {
delete details.responseHeaders["x-frame-options"];
}
callback({
cancel: false,
responseHeaders: details.responseHeaders,
});
},
);
mainWindowState.manage(mainWindow);
const template = [
{
label: app.name,
submenu: [
{
label: "About Flixerr",
role: "about",
},
{
type: "separator",
},
{
role: "services",
},
{
type: "separator",
},
{
label: "Hide Flixerr",
role: "hide",
},
{
role: "hideothers",
},
{
label: "Show Flixerr",
role: "show",
},
{
type: "separator",
},
{
label: "Quit Flixerr",
role: "quit",
},
],
},
{
role: "help",
submenu: [
{
label: "Learn More",
click() {
shell.openExternal("https://www.flixerr.co");
},
},
],
},
];
if (process.platform === "darwin") {
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
} else {
Menu.setApplicationMenu(null);
}
mainWindow.loadFile(path.join(__dirname, "index.html"));
if (global.dev) mainWindow.webContents.openDevTools();
mainWindow.webContents.once("dom-ready", () => {
mainWindow.show();
});
mainWindow.on("closed", function() {
mainWindow = null;
});
}
app.on("ready", createWindow);
app.on("window-all-closed", function() {
app.quit();
});
app.on("activate", function() {
if (mainWindow === null) createWindow();
});