ee-core 1.5.0 → 1.5.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -234,7 +234,11 @@ module.exports = appInfo => {
234
234
  protocol: 'http://',
235
235
  host: '127.0.0.1',
236
236
  port: 7072, // 默认端口(如果端口被使用,则随机获取一个)
237
- options: {}
237
+ options: {},
238
+ ssl: {
239
+ key: '',
240
+ cert: ''
241
+ }
238
242
  };
239
243
 
240
244
  /**
package/lib/eeApp.js CHANGED
@@ -1,10 +1,13 @@
1
1
  const path = require('path');
2
+ const fs = require('fs');
3
+ const assert = require('assert');
2
4
  const getPort = require('get-port');
3
5
  const {app, BrowserWindow, BrowserView, Menu} = require('electron');
4
6
  const BaseApp = require('./baseApp');
5
7
  const is = require('is-type-of');
6
8
  const Koa = require('koa');
7
9
  const koaServe = require('koa-static');
10
+ const https = require('https');
8
11
  const utilsCommon = require('../utils/common');
9
12
 
10
13
  class EeApp extends BaseApp {
@@ -236,9 +239,29 @@ class EeApp extends BaseApp {
236
239
  url += '/' + hostInfo.indexPage;
237
240
  }
238
241
 
239
- koaApp.listen(mainServer.port, () => {
240
- self.loadMainUrl(mode, url);
241
- });
242
+ const isHttps = mainServer.protocol == 'https://' ? true : false;
243
+ if (isHttps) {
244
+ const keyFile = path.join(this.config.homeDir, mainServer.ssl.key);
245
+ const certFile = path.join(this.config.homeDir, mainServer.ssl.cert);
246
+ assert(fs.existsSync(keyFile), 'ssl key file is required');
247
+ assert(fs.existsSync(certFile), 'ssl cert file is required');
248
+
249
+ const sslOpt = {
250
+ key: fs.readFileSync(keyFile),
251
+ cert: fs.readFileSync(certFile)
252
+ };
253
+ https.createServer(sslOpt, koaApp.callback()).listen(mainServer.port, (err) => {
254
+ if (err) {
255
+ self.coreLogger.info('[error] ', err);
256
+ return
257
+ }
258
+ self.loadMainUrl(mode, url);
259
+ });
260
+ } else {
261
+ koaApp.listen(mainServer.port, () => {
262
+ self.loadMainUrl(mode, url);
263
+ });
264
+ }
242
265
  }
243
266
 
244
267
  /**
@@ -246,7 +269,8 @@ class EeApp extends BaseApp {
246
269
  */
247
270
  loadMainUrl (type, url) {
248
271
  const mainServer = this.config.mainServer;
249
- this.logger.info('main page is env: %s, type: %s, App running at: %s', this.config.env, type, url);
272
+ this.logger.info('[ee-core:main] Env: %s, Type: %s', this.config.env, type);
273
+ this.logger.info('[ee-core:main] App running at: %s', url);
250
274
  this.electron.mainWindow.loadURL(url, mainServer.options);
251
275
  }
252
276
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-core",
3
- "version": "1.5.0",
3
+ "version": "1.5.1-beta.1",
4
4
  "description": "ee core",
5
5
  "main": "index.js",
6
6
  "scripts": {