index.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * This file is part of Moeditor.
  3. *
  4. * Copyright (c) 2016 Menci <huanghaorui301@gmail.com>
  5. * Copyright (c) 2015 Thomas Brouard (for codes from Abricotine)
  6. *
  7. * Moeditor is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Moeditor is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Moeditor. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. 'use strict';
  21. const app = require('electron').app,
  22. MoeditorApplication = require('./moe-app');
  23. var moeApp = null, openFile = null;
  24. app.on("ready", () => {
  25. moeApp = new MoeditorApplication();
  26. global.moeApp = moeApp;
  27. global.app = app;
  28. app.moeApp = moeApp;
  29. if (openFile !== null)
  30. moeApp.osxOpenFile = openFile;
  31. moeApp.run();
  32. });
  33. app.on('window-all-closed', () => {
  34. if (process.platform !== 'darwin') {
  35. app.quit();
  36. }
  37. });
  38. app.on('open-file', (e, file) => {
  39. if (moeApp === null) openFile = file;
  40. else moeApp.open(file);
  41. });
  42. app.on('activate', () => {
  43. if (moeApp != null && moeApp.windows && moeApp.windows.length == 0) {
  44. moeApp.open();
  45. }
  46. });