-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
50 lines (42 loc) · 1.18 KB
/
index.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
const { app, BrowserWindow, globalShortcut } = require( 'electron' );
const os = require( 'os' );
let mainWindow = null;
app.setName( 'Micrungeon' );
app.on( 'ready', () => {
mainWindow = new BrowserWindow( {
backgroundColor: 'lightgray',
title: 'Micrungeon',
show: false,
webPreferences: {
nodeIntegration: true,
defaultEncoding: 'UTF-8'
}
} );
mainWindow.setFullScreen( true );
const platform = os.platform();
if ( platform === 'darwin' ) {
globalShortcut.register( 'Command+Option+I', () => {
mainWindow.webContents.openDevTools();
} );
}
else if ( platform === 'linux' || platform === 'win32' ) {
globalShortcut.register( 'Control+Shift+I', () => {
mainWindow.webContents.openDevTools();
} );
}
mainWindow.once( 'ready-to-show', () => {
mainWindow.setMenu( null );
mainWindow.show();
} );
mainWindow.onbeforeunload = ( e ) => {
// Prevent Command-R from unloading the window contents.
e.returnValue = false;
};
mainWindow.on( 'closed', () => {
mainWindow = null;
} );
mainWindow.loadURL( `file://${__dirname}/app/index.html` );
} );
app.on( 'window-all-closed', () => {
app.quit();
} );