Initial commit

This commit is contained in:
Nuintun
2015-11-20 12:47:35 +08:00
parent 72f3cc1ad8
commit a20d1def1b
29 changed files with 12094 additions and 0 deletions

59
bin/window-control.js Normal file
View File

@@ -0,0 +1,59 @@
/**
* Created by nuintun on 2015/11/18.
*/
'use strict';
// module to control application life
var ipc = require('ipc-main');
/**
* window control
* @param icon
* @param window
* @param tray
*/
module.exports = function (icon, window, tray){
// bind maximize event
window.on('maximize', function (event){
event.sender.send('is-maximized', true);
});
// bind unmaximize event
window.on('unmaximize', function (event){
event.sender.send('is-maximized', false);
});
// bind tray double-click event
tray.on('double-click', function (){
window.show();
});
// listen window ipc
ipc.on('window', function (event, command){
switch (command) {
case 'tray':
var title = window.getTitle();
window.hide();
tray.displayBalloon({
icon: icon,
title: title,
content: title + '正在后台运行!'
});
break;
case 'close':
window.close();
break;
case 'maximize':
window.maximize();
break;
case 'unmaximize':
window.unmaximize();
break;
case 'is-maximized':
event.sender.send('is-maximized', window.isMaximized());
break;
}
});
};