moe-about.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * This file is part of Moeditor.
  3. *
  4. * Copyright (c) 2016 Menci <huanghaorui301@gmail.com>
  5. *
  6. * Moeditor is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * Moeditor is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with Moeditor. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. 'use strict';
  20. const {BrowserWindow, ipcMain} = require('electron');
  21. var aboutWindow;
  22. function showAboutWindow() {
  23. if (typeof aboutWindow !== 'undefined') {
  24. if (aboutWindow.isMinimized())
  25. aboutWindow.restore();
  26. aboutWindow.focus();
  27. return;
  28. }
  29. const debug = (moeApp.flag.debug | moeApp.config.get('debug')) != 0;
  30. var conf = {
  31. icon: Const.path + "/icons/HexoEditor.ico",
  32. autoHideMenuBar: true,
  33. width: 660,
  34. height: 290,
  35. webPreferences: {
  36. zoomFactor: moeApp.config.get('scale-factor')
  37. },
  38. resizable: false,
  39. maximizable: false,
  40. show: debug
  41. };
  42. if (process.platform == 'darwin') conf.titleBarStyle = 'hidden-inset';
  43. else conf.frame = false;
  44. aboutWindow = new BrowserWindow(conf);
  45. aboutWindow.loadURL('file://' + Const.path + '/views/about/about.html');
  46. if (debug) aboutWindow.webContents.openDevTools();
  47. aboutWindow.webContents.on('close', () => {
  48. aboutWindow = undefined;
  49. })
  50. }
  51. function closeWindow() {
  52. if (typeof aboutWindow !== 'undefined')
  53. aboutWindow.close()
  54. }
  55. ipcMain.on('show-about-window', showAboutWindow);
  56. ipcMain.on('close-all-window', closeWindow);
  57. module.exports = showAboutWindow;