-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.js
100 lines (87 loc) · 2.12 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* Amy is Awesome!
*/
'use strict';
const app = require('app');
const ipc = require('ipc');
const BrowserWindow = require('browser-window');
const Menu = require('menu');
const angular = require('./client/lib/ng-electron/ng-bridge');
function createMainWindow () {
const win = new BrowserWindow({
width: 800,
height: 600,
resizable: false
});
win.loadUrl(`file://${__dirname}/index.html`);
win.on('closed', onClosed);
return win;
}
function onClosed() {
mainWindow = null;
}
// prevent window being GC'd
let mainWindow;
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate-with-no-open-windows', function () {
if (!mainWindow) {
mainWindow = createMainWindow();
}
});
app.on('will-quit', function() {
console.log('<====================================>');
console.log('Amy Says, "Stay Awesome Kids!"');
console.log('<====================================>');
});
app.on('ready', function () {
mainWindow = createMainWindow();
console.log('<====================================>');
console.log("Amy says, \"Let's Code Awesome!\"");
console.log('<====================================>');
mainWindow.webContents.on('dom-ready', function(e) {
//try and manually bootstrap AngularJS
var code = "angular.bootstrap(document, ['app']);"
mainWindow.webContents.executeJavaScript( code );
});
mainWindow.webContents.on('did-finish-load', function( e ) {
var menu = new Menu();
var tpl = [
{
label: 'Amy',
submenu: [
{
label: 'About Amy',
click: function() { console.log('Version 1.Amy.Awesome!'); }
},
{
label: 'Quit',
click: function() { app.quit(); },
accelerator: 'Command+Q'
}
]
},
{
label: 'Actions',
submenu: [
{
label: 'Host to Client',
click: function ( msg ) {
var msg = 'Host: Hiya Amy App Stack!';
angular.send( msg );
}
}
]
}
];
menu = Menu.buildFromTemplate( tpl );
Menu.setApplicationMenu(menu);
//Start listening for client messages
angular.listen(function(msg) {
console.log('Client: ' + msg);
});
});
});