ee-core 1.5.0-beta.1 → 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.
- package/config/config.default.js +5 -1
- package/lib/eeApp.js +28 -4
- package/package.json +1 -1
package/config/config.default.js
CHANGED
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
|
-
|
|
240
|
-
|
|
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
|
|
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
|
|