Desktop markdown wiki app. Built with node, Electron Framework and AngularJS.

app.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. var app = require('app'); // Module to control application life.
  2. var BrowserWindow = require('browser-window'); // Module to create native browser window.
  3. var ipc = require('ipc');
  4. // Keep a global reference of the window object, if you don't, the window will
  5. // be closed automatically when the JavaScript object is garbage collected.
  6. var mainWindow = null;
  7. var preferencesWindow = null;
  8. var createMainWindow = function() {
  9. // Create the browser window.
  10. mainWindow = new BrowserWindow({
  11. width: 1030,
  12. height: 700,
  13. 'min-width': 500,
  14. 'min-height': 200,
  15. 'accept-first-mouse': true,
  16. 'title-bar-style': 'hidden',
  17. 'fullscreen' : true
  18. });
  19. // and load the index.html of the app.
  20. mainWindow.loadUrl('file://' + __dirname + '/app/index.html');
  21. // Open the DevTools.
  22. //mainWindow.openDevTools();
  23. // Emitted when the window is closed.
  24. mainWindow.on('closed', function() {
  25. // Dereference the window object, usually you would store windows
  26. // in an array if your app supports multi windows, this is the time
  27. // when you should delete the corresponding element.
  28. mainWindow = null;
  29. });
  30. }
  31. var createPreferencesWindow = function() {
  32. if(preferencesWindow === null){
  33. preferencesWindow = new BrowserWindow({
  34. width: 500,
  35. height: 300,
  36. show: true,
  37. resizable: false,
  38. 'title-bar-style': 'hidden',
  39. 'fullscreen' : false
  40. });
  41. preferencesWindow.loadUrl('file://' + __dirname + '/app/preferences-window.html');
  42. preferencesWindow.on('closed', function() {
  43. preferencesWindow = null;
  44. });
  45. }
  46. }
  47. // Quit when all windows are closed.
  48. app.on('window-all-closed', function() {
  49. // On OS X it is common for applications and their menu bar
  50. // to stay active until the user quits explicitly with Cmd + Q
  51. if (process.platform != 'darwin') {
  52. app.quit();
  53. }
  54. });
  55. // This method will be called when Electron has finished
  56. // initialization and is ready to create browser windows.
  57. app.on('ready', function() {
  58. createMainWindow();
  59. //createPreferencesWindow();
  60. ipc.on('show-preferences-window', function() {
  61. createPreferencesWindow();
  62. });
  63. });