import { MenuType } from '../module/menu/enum/MenuType'; import * as ReactDOM from 'react-dom'; import { Global } from '../utils/Global'; import { Paths } from '../utils/Paths'; import { MainGlobal } from './utils/MainGlobal'; import { ModuleList } from './module/ModuleList'; import { EventManager } from '../leo/frame/manager/EventManager'; import { E_InitEvent } from './module/init/E_InitEvent'; import { Dialog } from './module/dialog/Dialog'; import { App } from './module/application/App'; //GUI模块或者系统底层模块只能在主进程中使用。 const electron = require('electron') // 控制整个应用的生命周期 const app = electron.app; const ipcMain: Electron.IpcMain = electron.ipcMain; // Module to create native browser window. const BrowserWindow = electron.BrowserWindow const session = electron.session; const path = require('path') const url = require('url') const Menu = electron.Menu; const MenuItem = electron.MenuItem; const debug = /--debug/.test(process.argv[3]); // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the JavaScript object is garbage collected. let mainWindow: Electron.BrowserWindow; function createWindow() { let windowOptions = { width: 1080, height: 840, minWidth: 680, title: app.getName(), icon: "assets/app-icon/png/32.png", frame: true }; // Create the browser window. mainWindow = new BrowserWindow(windowOptions); //and load the index.html of the app. mainWindow.loadURL(url.format({ pathname: path.resolve(__dirname, "../../", 'index.html'), protocol: 'file:', slashes: true })); mainWindow.maximize(); MainGlobal.mainWindow = mainWindow; var webContent: Electron.WebContents = mainWindow.webContents; // Emitted when the window is closed. mainWindow.on('closed', function () { // Dereference the window object, usually you would store windows // in an array if your app supports multi windows, this is the time // when you should delete the corresponding element. mainWindow = null }) ModuleList.start(); EventManager.dispatchModuleEvent(new E_InitEvent()); } // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. app.on('ready', createWindow); app.on('activate', function () { // On OS X it's common to re-create a window in the app when the // dock icon is clicked and there are no other windows open. if (mainWindow === null) { createWindow() } }); App.onMessage(); Dialog.onMessage();