ee-core 1.1.0 → 1.1.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.
- package/core/lib/ee.js +2 -1
- package/core/lib/loader/ee_loader.js +14 -2
- package/lib/application.js +7 -3
- package/lib/eeApp.js +4 -8
- package/package.json +2 -2
- package/utils/index.js +3 -1
package/core/lib/ee.js
CHANGED
|
@@ -38,7 +38,7 @@ class EeLoader {
|
|
|
38
38
|
* @see {@link AppInfo#pkg}
|
|
39
39
|
* @since 1.0.0
|
|
40
40
|
*/
|
|
41
|
-
this.pkg =
|
|
41
|
+
this.pkg = this.getPkg();
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Framework directories
|
|
@@ -127,7 +127,7 @@ class EeLoader {
|
|
|
127
127
|
debug('Loaded appname(%s) from package.json', this.pkg.name);
|
|
128
128
|
return this.pkg.name;
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
throw new Error(`name is required from ${pkg}`);
|
|
132
132
|
}
|
|
133
133
|
|
|
@@ -407,6 +407,18 @@ class EeLoader {
|
|
|
407
407
|
|
|
408
408
|
return fullPath;
|
|
409
409
|
}
|
|
410
|
+
|
|
411
|
+
getPkg() {
|
|
412
|
+
//let filePath = '';
|
|
413
|
+
// let variablePath = 'build'; // 打包前路径
|
|
414
|
+
// if (this.options.isPackaged) {
|
|
415
|
+
// variablePath = '..'; // 打包后路径
|
|
416
|
+
// }
|
|
417
|
+
// filePath = path.join(app.getAppPath(), variablePath, "package.json");
|
|
418
|
+
|
|
419
|
+
const content = utility.readJSONSync(path.join(this.options.homeDir, 'package.json'));
|
|
420
|
+
return content;
|
|
421
|
+
}
|
|
410
422
|
}
|
|
411
423
|
|
|
412
424
|
/**
|
package/lib/application.js
CHANGED
|
@@ -10,19 +10,23 @@ class Appliaction extends EeApp {
|
|
|
10
10
|
// const opt = this.initEnv();
|
|
11
11
|
const { env } = process;
|
|
12
12
|
|
|
13
|
+
// 路径不能使用绝对,打包前后有问题
|
|
14
|
+
|
|
15
|
+
|
|
13
16
|
let options = {
|
|
14
17
|
env: 'prod',
|
|
15
18
|
serverScope: '',
|
|
16
19
|
type: 'application',
|
|
17
20
|
baseDir: path.join(app.getAppPath(), 'electron'),
|
|
18
|
-
homeDir:
|
|
19
|
-
framework: path.join(
|
|
21
|
+
homeDir: app.getAppPath(),
|
|
22
|
+
framework: path.join(app.getAppPath(), 'node_modules', 'ee-core'),
|
|
20
23
|
appName: app.getName(),
|
|
21
24
|
userHome: app.getPath('home'),
|
|
22
25
|
appData: app.getPath('appData'),
|
|
23
26
|
appUserData: app.getPath('userData'),
|
|
24
27
|
logsDir: app.getPath('logs'),
|
|
25
|
-
appVersion: app.getVersion()
|
|
28
|
+
appVersion: app.getVersion(),
|
|
29
|
+
isPackaged: app.isPackaged
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
// argv
|
package/lib/eeApp.js
CHANGED
|
@@ -82,7 +82,7 @@ class EeApp extends BaseApp {
|
|
|
82
82
|
this.electron.mainWindow = new BrowserWindow(winOptions);
|
|
83
83
|
|
|
84
84
|
// 隐藏菜单
|
|
85
|
-
if (this.config.openAppMenu) {
|
|
85
|
+
if (!this.config.openAppMenu) {
|
|
86
86
|
Menu.setApplicationMenu(null);
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -234,7 +234,6 @@ class EeApp extends BaseApp {
|
|
|
234
234
|
* egg
|
|
235
235
|
*/
|
|
236
236
|
startEgg (argv) {
|
|
237
|
-
const startCluster = require('egg-cluster').startCluster;
|
|
238
237
|
|
|
239
238
|
let homeDir = this.homeDir;
|
|
240
239
|
argv.baseDir = homeDir;
|
|
@@ -256,12 +255,9 @@ class EeApp extends BaseApp {
|
|
|
256
255
|
const clusterOptions = this.stringify(argv, ignoreKeys);
|
|
257
256
|
const options = JSON.parse(clusterOptions);
|
|
258
257
|
this.coreLogger.info('[ee-core:EeApp] [startEgg] options', options);
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
resolve('success');
|
|
263
|
-
});
|
|
264
|
-
});
|
|
258
|
+
if (is.function(this.startEggCluster)) {
|
|
259
|
+
return this.startEggCluster(options);
|
|
260
|
+
}
|
|
265
261
|
}
|
|
266
262
|
|
|
267
263
|
/**
|
package/package.json
CHANGED
package/utils/index.js
CHANGED
|
@@ -50,7 +50,9 @@ exports.chmodPath = function(path, mode) {
|
|
|
50
50
|
* 获取项目根目录package.json
|
|
51
51
|
*/
|
|
52
52
|
exports.getPackage = function() {
|
|
53
|
-
const
|
|
53
|
+
const cdb = this.getCoreDB();
|
|
54
|
+
const config = cdb.getItem('config');
|
|
55
|
+
const filePath = path.join(config.homeDir, 'package.json');
|
|
54
56
|
const json = require(filePath);
|
|
55
57
|
|
|
56
58
|
return json;
|