-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.js
74 lines (59 loc) · 1.84 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
const electron = require('electron');
const JSONStorage = require('node-localstorage').JSONStorage;
const config = require('./app/config');
const menuTemplate = require(`./menus/${process.platform === 'darwin' ? 'darwin' : 'other'}`);
const app = electron.app;
const Menu = electron.Menu;
const BrowserWindow = electron.BrowserWindow;
const isDev = (process.env.NODE_ENV === 'development');
let mainWindow = null;
let menu = null;
if (isDev) {
require('electron-debug')();
}
function installExtensions() {
const installer = require('electron-devtools-installer');
const extensions = [
'REACT_DEVELOPER_TOOLS'
];
extensions.forEach((extension) => {
installer.default(installer[extension]);
});
}
app.on('window-all-closed', function() {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('ready', function() {
if (isDev) {
installExtensions();
}
const storage = new JSONStorage(isDev ? config.devUserData : app.getPath('userData'));
const settings = storage.getItem('reduxPersist:settings');
let width = config.maxSize.width;
let height = config.maxSize.height;
if (settings && settings.minimize) {
width = config.minSize.width;
height = config.minSize.height;
}
mainWindow = new BrowserWindow({
width: width,
height: height,
show: false,
resizable: isDev,
backgroundColor: config.backgroundColor,
fullscreen: false,
frame: false
});
menu = Menu.buildFromTemplate(menuTemplate());
Menu.setApplicationMenu(menu);
mainWindow.loadURL(`file://${__dirname}/app/app.html`);
mainWindow.webContents.on('did-finish-load', () => {
mainWindow.show();
mainWindow.focus();
});
mainWindow.on('closed', function() {
mainWindow = null;
});
});