ee-core 2.7.0-beta.1 → 2.7.0-beta.3

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.
@@ -0,0 +1,39 @@
1
+ const EE = require('../ee');
2
+
3
+ const conf = {
4
+
5
+ /**
6
+ * 获取 内存中的config
7
+ */
8
+ _getConfig() {
9
+ const { CoreApp } = EE;
10
+ if (!CoreApp) {
11
+ throw new Error(`[ee-core] [config] Frame initialization is not complete !`);
12
+ }
13
+
14
+ return CoreApp.config;
15
+ },
16
+
17
+ /**
18
+ * all
19
+ */
20
+ all() {
21
+ return this._getConfig();
22
+ },
23
+
24
+ /**
25
+ * getValue
26
+ */
27
+ getValue(key) {
28
+ const v = this._objectGet(this._getConfig(), key);
29
+ return v;
30
+ },
31
+
32
+ _objectGet(object, path, defaultValue) {
33
+ const pathParts = Array.isArray(path) ? path : path.split('.');
34
+ const value = pathParts.reduce((obj, key) => obj && key in obj ? obj[key] : undefined, object);
35
+ return value === undefined ? defaultValue : value;
36
+ }
37
+ };
38
+
39
+ module.exports = conf;
package/cross/index.js CHANGED
@@ -2,7 +2,7 @@ const fs = require('fs');
2
2
  const crossSpawn = require('cross-spawn');
3
3
  const path = require('path');
4
4
  const is = require('is-type-of');
5
- const Conf = require('../config');
5
+ const Conf = require('../config/cache');
6
6
  const UtilsHelper = require('../utils/helper');
7
7
  const UtilsIs = require('../utils/is');
8
8
  const UtilsPargv = require('../utils/pargv');
@@ -97,8 +97,11 @@ const CrossLanguageService = {
97
97
  return arr;
98
98
  },
99
99
 
100
- getUrl(argv) {
101
- const args = this.getArgs(argv);
100
+ getUrl(service) {
101
+ const cfg = Conf.getValue('cross');
102
+ const servicesCfg = cfg[service];
103
+
104
+ const args = this.getArgs(servicesCfg.args);
102
105
  let protocol = 'http://';
103
106
  if (args.hasOwnProperty('ssl') && (args.ssl == 'true' || args.ssl == '1')) {
104
107
  protocol = 'https://';
package/ee/eeApp.js CHANGED
@@ -121,12 +121,13 @@ class EeApp extends BaseApp {
121
121
  let url;
122
122
  let load = 'url';
123
123
  const configFile = './electron/config/bin.js';
124
+ let electronCfg = {};
124
125
 
125
126
  const isBin = UtilsHelper.checkConfig(configFile);
126
127
  if (isBin) {
127
128
  const binConfig = UtilsHelper.loadConfig(configFile);
128
- const { frontend } = binConfig.dev;
129
- modeInfo = frontend;
129
+ modeInfo = binConfig.dev.frontend;
130
+ electronCfg = binConfig.dev.electron;
130
131
  } else {
131
132
  // 兼容旧的 developmentMode
132
133
  const developmentModeConfig = this.config.developmentMode;
@@ -142,8 +143,13 @@ class EeApp extends BaseApp {
142
143
 
143
144
  // 检查 UI serve是否启动,先加载一个boot page
144
145
  if (load == 'url') {
145
- const bootPage = path.join(__dirname, '..', 'html', 'boot.html');
146
- this.mainWindow.loadFile(bootPage);
146
+ // loading page
147
+ let lp = path.join(__dirname, '..', 'html', 'boot.html');
148
+ if (electronCfg.hasOwnProperty('loadingPage') && electronCfg.loadingPage != '') {
149
+ lp = path.join(this.config.homeDir, electronCfg.loadingPage);
150
+ }
151
+ this._loadingPage(lp);
152
+
147
153
  let count = 0;
148
154
  let frontendReady = false;
149
155
  const hc = new HttpClient();
@@ -197,15 +203,22 @@ class EeApp extends BaseApp {
197
203
  const crossConfig = this.config.cross;
198
204
 
199
205
  // loading page
200
- this._loadingPage(mainCfg);
206
+ if (mainCfg.hasOwnProperty('loadingPage')) {
207
+ const lp = path.join(this.config.homeDir, mainCfg.loadingPage);
208
+ this._loadingPage(lp);
209
+ }
201
210
 
202
211
  // cross service url
203
- if (!crossConfig.hasOwnProperty(mainCfg.takeover)) {
204
- Log.coreLogger.error(`[ee-core] Please check cross config !`);
212
+ const service = mainCfg.takeover;
213
+ if (!crossConfig.hasOwnProperty(service)) {
205
214
  throw new Error(`[ee-core] Please Check the value of mainServer.takeover in the config file !`);
206
215
  }
207
- const servicesCfg = crossConfig[mainCfg.takeover];
208
- const url = Cross.getUrl(servicesCfg.args);
216
+ // check service
217
+ if (crossConfig[service].enable != true) {
218
+ throw new Error(`[ee-core] Please Check the value of cross.${service} enable is true !`);
219
+ }
220
+
221
+ const url = Cross.getUrl(service);
209
222
 
210
223
  let count = 0;
211
224
  let serviceReady = false;
@@ -231,11 +244,10 @@ class EeApp extends BaseApp {
231
244
  if (serviceReady == false) {
232
245
  const bootFailurePage = path.join(__dirname, '..', 'html', 'cross-failure.html');
233
246
  this.mainWindow.loadFile(bootFailurePage);
234
- Log.coreLogger.error(`[ee-core] Please check cross service [${mainCfg.takeover}] ${url} !`);
235
- return;
247
+ throw new Error(`[ee-core] Please check cross service [${service}] ${url} !`)
236
248
  }
237
249
 
238
- Log.coreLogger.info(`[ee-core] cross service [${mainCfg.takeover}] is started successfully`);
250
+ Log.coreLogger.info(`[ee-core] cross service [${service}] is started successfully`);
239
251
  this.loadMainUrl('spa', url);
240
252
  }
241
253
 
@@ -309,14 +321,12 @@ class EeApp extends BaseApp {
309
321
  /**
310
322
  * loading page
311
323
  */
312
- _loadingPage(mainCfg = {}) {
313
- const p = mainCfg.hasOwnProperty('loadingPage') ? mainCfg.loadingPage : 'unknown';
314
- const lp = path.join(this.config.homeDir, p);
315
- if (!fs.existsSync(lp)) {
324
+ _loadingPage(name) {
325
+ if (!fs.existsSync(name)) {
316
326
  return
317
327
  }
318
328
 
319
- this.mainWindow.loadFile(lp);
329
+ this.mainWindow.loadFile(name);
320
330
  }
321
331
 
322
332
  /**
@@ -21,7 +21,7 @@
21
21
  <body>
22
22
  <div id="failure">
23
23
  <div class='base'>
24
- Booting failure, please check cross service is runing !
24
+ Startup failed, please check cross service is runing !
25
25
  </div>
26
26
  </div>
27
27
  </body>
package/html/failure.html CHANGED
@@ -21,7 +21,7 @@
21
21
  <body>
22
22
  <div id="failure">
23
23
  <div class='base'>
24
- Booting failure, please check frontend service is runing !
24
+ Startup failed, please check frontend service is runing !
25
25
  </div>
26
26
  </div>
27
27
  </body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-core",
3
- "version": "2.7.0-beta.1",
3
+ "version": "2.7.0-beta.3",
4
4
  "description": "ee core",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -15,6 +15,7 @@
15
15
  "agentkeepalive": "^4.2.0",
16
16
  "bytenode": "^1.3.6",
17
17
  "chalk": "^4.1.2",
18
+ "cross-spawn": "^7.0.3",
18
19
  "dayjs": "^1.11.7",
19
20
  "debug": "^4.3.3",
20
21
  "egg-errors": "^2.3.0",