ee-core 2.7.0-beta.1 → 2.7.0-beta.2
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/cache.js +39 -0
- package/cross/index.js +6 -3
- package/ee/eeApp.js +27 -17
- package/package.json +1 -1
package/config/cache.js
ADDED
|
@@ -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(
|
|
101
|
-
const
|
|
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
|
-
|
|
129
|
-
|
|
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
|
-
|
|
146
|
-
|
|
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
|
-
|
|
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
|
-
|
|
204
|
-
|
|
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
|
-
|
|
208
|
-
|
|
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
|
-
|
|
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 [${
|
|
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(
|
|
313
|
-
|
|
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(
|
|
329
|
+
this.mainWindow.loadFile(name);
|
|
320
330
|
}
|
|
321
331
|
|
|
322
332
|
/**
|