forked from MSFS-Mega-Pack/MSFS2020-livery-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
136 lines (115 loc) · 3.09 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
130
131
132
133
134
135
136
const path = require('path');
const url = require('url');
const { app, BrowserWindow, globalShortcut } = require('electron');
const open = require('open');
const { checkForUpdates } = require('./updater');
const Sentry = require('@sentry/electron');
app.commandLine.appendSwitch('disable-http-cache');
/** @type {BrowserWindow} */
let mainWindow;
let isDev = false;
if (process.env.NODE_ENV && process.env.NODE_ENV === 'development') {
isDev = true;
}
if (!isDev) {
if (require('electron-squirrel-startup')) {
app.quit();
process.exit(0);
}
app.whenReady().then(() => {
globalShortcut.register('CommandOrControl+R', () => {
console.log('CommandOrControl+R is pressed: Shortcut Disabled');
});
globalShortcut.register('F5', () => {
console.log('F5 is pressed: Shortcut Disabled');
});
});
//! Uncomment to prevent program running after install
// if (process.platform === 'win32') {
// var cmd = process.argv[1];
// if (cmd === '--squirrel-firstrun') {
// app.quit();
// process.exit(0);
// }
// }
Sentry.init({
dsn: 'https://ac6e425a093744a0a72e061986c2f138@o252778.ingest.sentry.io/5431856',
environment: process.env.NODE_ENV,
enableNative: true,
debug: true,
attachStacktrace: true,
});
}
function createMainWindow() {
mainWindow = new BrowserWindow({
minWidth: 900,
minHeight: 700,
width: 1000,
height: 750,
frame: false,
darkTheme: true,
backgroundColor: '#1b1b31',
titleBarStyle: 'hidden',
show: false,
icon: `${__dirname}/assets/icon.ico`,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
enableRemoteModule: true,
webSecurity: false,
preload: path.join(__dirname, 'src', 'helpers', 'Sentry', 'sentry.js'),
devTools: true,
worldSafeExecuteJavaScript: true,
allowRunningInsecureContent: false,
},
});
let indexPath;
if (isDev && process.argv.indexOf('--noDevServer') === -1) {
indexPath = url.format({
protocol: 'http:',
host: 'localhost:8080',
pathname: 'index.html',
slashes: true,
});
} else {
indexPath = url.format({
protocol: 'file:',
pathname: path.join(__dirname, 'dist', 'index.html'),
slashes: true,
});
}
// open new window links in the default browser
mainWindow.webContents.on('new-window', (event, url) => {
event.preventDefault();
open(url);
});
mainWindow.menuBarVisible = false;
mainWindow.loadURL(indexPath);
if (!isDev) {
checkForUpdates(mainWindow);
}
// Don't show until we are ready and loaded
mainWindow.once('ready-to-show', () => {
mainWindow.show();
// Open devtools if dev
if (isDev) {
mainWindow.webContents.openDevTools();
}
});
mainWindow.on('closed', () => (mainWindow = null));
}
app.on('ready', () => {
createMainWindow();
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (mainWindow === null) {
createMainWindow();
}
});
// Stop error
app.allowRendererProcessReuse = true;