-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
46 lines (36 loc) · 1.13 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
'use strict';
import Config from './config/config.json';
import Path from 'path'
import is from 'electron-is';
const { app, BrowserWindow, shell } = require('electron');
let win;
const createWindow = () => {
win = new BrowserWindow({
title : app.getName(),
width : Config.windowWidth,
height : Config.windowHeight,
minWidth : Config.windowMinWidth,
minHeight : Config.windowMinHeight,
center : true,
show : false,
webPreferences : {
defaultEncoding : 'UTF-8',
webaudio : false,
webgl : false
}
});
win.once('ready-to-show', () => win.show());
win.on('closed', () => win = null);
win.loadURL('file://' + Path.join(__dirname, 'app/index.html'));
win.webContents.on('will-navigate', (e, url) => {
e.preventDefault();
shell.openExternal(url);
});
}
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (!is.macOS()) app.quit();
});
app.on('activate', () => {
if (win === null) createWindow();
});