-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
86 lines (74 loc) · 2.85 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
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
/* global __dirname */
var app = require('app');
var BrowserWindow = require('browser-window');
var ipc = require('ipc');
var MenusManager = require('./src/MenusManager.js');
require("babel-core/register");
// Report crashes to our server.
require('crash-reporter').start();
// console.log('app.getAppPath() -> ', app.getAppPath());
// console.log('app.getPath("home") -> ', app.getPath('home'));
// console.log('app.getPath("appData") -> ', app.getPath('appData'));
// console.log('app.getPath("userData") -> ', app.getPath('userData'));
// console.log('app.getPath("temp") -> ', app.getPath('temp'));
// console.log('app.getPath("userDesktop") -> ', app.getPath('userDesktop'));
// console.log('app.getPath("exe") -> ', app.getPath('exe'));
// console.log('app.getPath("module") -> ', app.getPath('module'));
// Load all the extension packages that are interested in working with the
// main process
// ------------------------------------------------------------------------------
var pkg = require('./package.json');
for (var name in pkg.ride.packages) {
var ext
try {
ext = require('./node_modules/' + name + '/ride-main-process.js')
} catch (err) {
// ignore
}
if (typeof ext == 'function') {
ext.call(this)
}
}
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
var mainWindow = null;
// This app uses custom header so we need to make it (un)maximize on dblclick
ipc.on('toggleMaximize', function() {
if (mainWindow) {
if (mainWindow.isMaximized()) {
mainWindow.unmaximize();
} else {
mainWindow.maximize();
}
}
});
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {
// Create the browser window.
mainWindow = new BrowserWindow({
width : 1200,
height : 800,
show : false,
center : true,
'min-width' : 400,
'min-height': 200,
'title-bar-style': 'hidden',
webSecurity : false,
allowDisplayingInsecureContent: true,
allowRunningInsecureContent: true
});
// and load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/dst/index.html');
// Open the DevTools.
mainWindow.openDevTools();
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
MenusManager.setMainMenu(mainWindow);
mainWindow.show();
});