ee-core 2.0.0-beta.4 → 2.0.0-beta.7

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.
Files changed (76) hide show
  1. package/addon/index.js +30 -0
  2. package/config/index.js +54 -0
  3. package/{module/const → const}/channel.js +4 -1
  4. package/{module/const → const}/index.js +1 -5
  5. package/{module/core → core}/lib/loader/ee_loader.js +1 -1
  6. package/{module/core → core}/lib/loader/file_loader.js +1 -0
  7. package/{module/core → core}/lib/loader/mixin/addon.js +1 -1
  8. package/{module/app → ee}/baseApp.js +2 -1
  9. package/{module/app → ee}/eeApp.js +20 -46
  10. package/ee/index.js +30 -0
  11. package/electron/index.js +32 -0
  12. package/electron/window.js +45 -0
  13. package/index.js +12 -13
  14. package/{module/jobs → jobs}/child/app.js +9 -15
  15. package/{module/jobs → jobs}/childPool/app.js +9 -15
  16. package/{module/message → message}/index.js +0 -2
  17. package/package.json +3 -5
  18. package/{module/ps → ps}/index.js +11 -4
  19. package/{module/socket → socket}/httpServer.js +12 -18
  20. package/socket/index.js +82 -0
  21. package/{module/socket → socket}/io.js +4 -0
  22. package/{module/socket → socket}/ipcServer.js +0 -2
  23. package/socket/socketServer.js +66 -0
  24. package/{module/storage → storage}/jsondbStorage.js +37 -0
  25. package/utils/is.js +145 -0
  26. package/module/app/index.js +0 -5
  27. package/module/socket/socketClient.js +0 -49
  28. package/module/socket/socketServer.js +0 -76
  29. package/module/socket/start.js +0 -22
  30. /package/{module/addon → addon}/window/index.js +0 -0
  31. /package/{module/bin → bin}/tools.js +0 -0
  32. /package/{module/config → config}/config.default.js +0 -0
  33. /package/{module/controller → controller}/index.js +0 -0
  34. /package/{module/core → core}/index.js +0 -0
  35. /package/{module/core → core}/lib/ee.js +0 -0
  36. /package/{module/core → core}/lib/loader/context_loader.js +0 -0
  37. /package/{module/core → core}/lib/loader/mixin/config.js +0 -0
  38. /package/{module/core → core}/lib/loader/mixin/controller.js +0 -0
  39. /package/{module/core → core}/lib/loader/mixin/service.js +0 -0
  40. /package/{module/core → core}/lib/utils/base_context_class.js +0 -0
  41. /package/{module/core → core}/lib/utils/function.js +0 -0
  42. /package/{module/core → core}/lib/utils/index.js +0 -0
  43. /package/{module/core → core}/lib/utils/sequencify.js +0 -0
  44. /package/{module/core → core}/lib/utils/timing.js +0 -0
  45. /package/{module/app → ee}/appLoader.js +0 -0
  46. /package/{module/app → ee}/application.js +0 -0
  47. /package/{module/exception → exception}/index.js +0 -0
  48. /package/{module/httpclient → httpclient}/index.js +0 -0
  49. /package/{module/jobs → jobs}/baseJobClass.js +0 -0
  50. /package/{module/jobs → jobs}/child/forkProcess.js +0 -0
  51. /package/{module/jobs → jobs}/child/index.js +0 -0
  52. /package/{module/jobs → jobs}/childPool/forkProcess.js +0 -0
  53. /package/{module/jobs → jobs}/childPool/index.js +0 -0
  54. /package/{module/jobs → jobs}/childPool/pool.js +0 -0
  55. /package/{module/jobs → jobs}/index.js +0 -0
  56. /package/{module/jobs → jobs}/renderer/index.js +0 -0
  57. /package/{module/jobs → jobs}/renderer/loadView.js +0 -0
  58. /package/{module/jobs → jobs}/unification.js +0 -0
  59. /package/{module/loader → loader}/index.js +0 -0
  60. /package/{module/log → log}/index.js +0 -0
  61. /package/{module/log → log}/logger.js +0 -0
  62. /package/{module/message → message}/childMessage.js +0 -0
  63. /package/{module/oldUtils → oldUtils}/index.js +0 -0
  64. /package/{module/service → service}/index.js +0 -0
  65. /package/{module/storage → storage}/index.js +0 -0
  66. /package/{module/storage → storage}/jsondb/adapters/Base.js +0 -0
  67. /package/{module/storage → storage}/jsondb/adapters/FileSync.js +0 -0
  68. /package/{module/storage → storage}/jsondb/main.js +0 -0
  69. /package/{module/storage → storage}/sqliteStorage.js +0 -0
  70. /package/{module/tools → tools}/encrypt.js +0 -0
  71. /package/{module/tools → tools}/replaceDist.js +0 -0
  72. /package/{module/utils → utils}/copyto.js +0 -0
  73. /package/{module/utils → utils}/helper.js +0 -0
  74. /package/{module/utils → utils}/index.js +0 -0
  75. /package/{module/utils → utils}/json.js +0 -0
  76. /package/{module/utils → utils}/wrap.js +0 -0
package/addon/index.js ADDED
@@ -0,0 +1,30 @@
1
+ const EEAddon = Symbol('Ee#Addon');
2
+
3
+ /**
4
+ * todo 插件模块
5
+ */
6
+ const Addon = {
7
+
8
+ /**
9
+ * 设置插件对象
10
+ */
11
+ setAddonObject(name, obj) {
12
+ if (!this[EEAddon]) {
13
+ this[EEAddon] = new Map();
14
+ }
15
+
16
+ if (!this[EEAddon].has(name)) {
17
+ this[EEAddon][name] = obj;
18
+ }
19
+ },
20
+
21
+ /**
22
+ * 获取插件对象
23
+ */
24
+ get(name) {
25
+ let addon = this[EEAddon].has(name) ? this[EEAddon][name]: null;
26
+ return addon;
27
+ },
28
+ }
29
+
30
+ module.exports = Addon;
@@ -0,0 +1,54 @@
1
+ const Storage = require('../storage');
2
+
3
+ const Cfg = {
4
+
5
+ /**
6
+ * 获取 coredb
7
+ */
8
+ _getCoreDB() {
9
+ const coreDB = Storage.connection('system');
10
+ return coreDB;
11
+ },
12
+
13
+ /**
14
+ * all
15
+ */
16
+ all() {
17
+ const cdb = this._getCoreDB();
18
+ const config = cdb.getItem('config');
19
+
20
+ return config;
21
+ },
22
+
23
+ /**
24
+ * setAll
25
+ */
26
+ setAll(value) {
27
+ const cdb = this._getCoreDB();
28
+ cdb.setItem('config', value);
29
+
30
+ return;
31
+ },
32
+
33
+ /**
34
+ * setValue
35
+ */
36
+ setValue(key, value) {
37
+ const cdb = this._getCoreDB();
38
+ cdb.setConfigItem(key, value);
39
+
40
+ return;
41
+ },
42
+
43
+ /**
44
+ * getValue
45
+ */
46
+ getValue(key) {
47
+ const cdb = this._getCoreDB();
48
+ let v = cdb.getConfigItem(key);
49
+
50
+ return v;
51
+ },
52
+ };
53
+
54
+ module.exports = Cfg;
@@ -2,5 +2,8 @@ module.exports = {
2
2
  process: {
3
3
  showException: 'ee#showException',
4
4
  sendToMain: 'ee#sendToMain'
5
- }
5
+ },
6
+ socketIo: {
7
+ partySoftware: 'c1',
8
+ },
6
9
  };
@@ -1,11 +1,7 @@
1
1
  module.exports = {
2
2
  storageKey: {
3
3
  cache: 'cache',
4
- },
5
- socketIo: {
6
- channel: {
7
- partySoftware: 'c1',
8
- }
4
+ cacheConfig: 'cache.config',
9
5
  },
10
6
  jobs: {
11
7
  inspectStartIndex: 5858
@@ -397,7 +397,7 @@ class EeLoader {
397
397
  }
398
398
 
399
399
  if (!fs.existsSync(filepath) && !fs.existsSync(fullpath)) {
400
- this.options.logger.warn(`[ee-core] [core/lib/loader/ee_loader] resolveModule unknow filepath: ${filepath}`)
400
+ //this.options.logger.warn(`[ee-core] [core/lib/loader/ee_loader] resolveModule unknow filepath: ${filepath}`)
401
401
  return undefined;
402
402
  }
403
403
  }
@@ -10,6 +10,7 @@ const deprecate = require('depd')('ee');
10
10
  const Utils = require('../utils');
11
11
  const FULLPATH = Symbol('EE_LOADER_ITEM_FULLPATH');
12
12
  const EXPORTS = Symbol('EE_LOADER_ITEM_EXPORTS');
13
+ const Addon = require('../../../addon');
13
14
 
14
15
  const defaults = {
15
16
  directory: null,
@@ -13,7 +13,7 @@ module.exports = {
13
13
 
14
14
  // 加载ee-core的插件 和 用户插件
15
15
  const directorys = [
16
- path.join(this.options.framework, 'module', 'addon'),
16
+ path.join(this.options.framework, 'addon'),
17
17
  path.join(this.options.baseDir, 'addon'),
18
18
  ]
19
19
  opt = Object.assign({
@@ -8,6 +8,7 @@ const HTTPCLIENT = Symbol('EeApplication#httpclient');
8
8
  const LOGGERS = Symbol('EeApplication#loggers');
9
9
  const Log = require('../log');
10
10
  const Storage = require('../storage');
11
+ const Conf = require('../config');
11
12
 
12
13
  class BaseApp extends EeAppCore {
13
14
  constructor (options = {}) {
@@ -17,7 +18,7 @@ class BaseApp extends EeAppCore {
17
18
  this.loader.loadConfig();
18
19
 
19
20
  // 缓存配置
20
- this.getCoreDB().setItem('config', this.config);
21
+ Conf.setAll(this.config);
21
22
 
22
23
  this.loader.load();
23
24
 
@@ -2,25 +2,24 @@ const path = require('path');
2
2
  const fs = require('fs');
3
3
  const assert = require('assert');
4
4
  const getPort = require('get-port');
5
- const {app, BrowserWindow, Menu, protocol} = require('electron');
5
+ const { app } = require('electron');
6
6
  const is = require('is-type-of');
7
7
  const Koa = require('koa');
8
8
  const koaServe = require('koa-static');
9
9
  const https = require('https');
10
10
  const BaseApp = require('./baseApp');
11
11
  const Log = require('../log');
12
+ const Electron = require('../electron');
13
+ const Conf = require('../config');
14
+ const Ps = require('../ps');
15
+ const Socket = require('../socket')
12
16
 
13
17
  class EeApp extends BaseApp {
14
18
  constructor(options = {}) {
15
19
  super(options);
16
20
 
17
- this.electron = {
18
- mainWindow: null,
19
- tray: null,
20
- extra: {
21
- closeWindow: false,
22
- },
23
- };
21
+ this.electron = Electron;
22
+ this.mainWindow;
24
23
  }
25
24
 
26
25
  /**
@@ -44,15 +43,14 @@ class EeApp extends BaseApp {
44
43
  }
45
44
 
46
45
  // 更新db配置
47
- this.getCoreDB().setItem('config', this.config);
46
+ Conf.setAll(this.config);
48
47
  }
49
48
 
50
49
  /**
51
50
  * 启动通信模块
52
51
  */
53
52
  async startSocket () {
54
- const socket = require('../socket/start');
55
- socket(this);
53
+ Socket.startAll(this);
56
54
  }
57
55
 
58
56
  /**
@@ -86,7 +84,7 @@ class EeApp extends BaseApp {
86
84
  })
87
85
 
88
86
  app.on('before-quit', () => {
89
- self.electron.extra.closeWindow = true;
87
+ Electron.extra.closeWindow = true;
90
88
  })
91
89
 
92
90
  if (this.config.hardGpu.enable == false) {
@@ -101,27 +99,8 @@ class EeApp extends BaseApp {
101
99
  */
102
100
  async createWindow () {
103
101
 
104
- // todo
105
- const protocolName = 'eefile';
106
- protocol.registerFileProtocol(protocolName, (request, callback) => {
107
- const url = request.url.substring(protocolName.length + 3);
108
- console.log('[ee-core] [lib/eeApp] registerFileProtocol ----url: ', url);
109
- callback({ path: path.normalize(decodeURIComponent(url)) })
110
- });
111
-
112
- const winOptions = this.config.windowsOption;
113
- this.electron.mainWindow = new BrowserWindow(winOptions);
114
- let win = this.electron.mainWindow;
115
-
116
- // 菜单显示/隐藏
117
- if (this.config.openAppMenu === 'dev-show'
118
- && this.config.env == 'prod') {
119
- Menu.setApplicationMenu(null);
120
- } else if (this.config.openAppMenu === false) {
121
- Menu.setApplicationMenu(null);
122
- } else {
123
- // nothing
124
- }
102
+ // 初始化一个主窗口
103
+ this.mainWindow = Electron.getMainWindow();
125
104
 
126
105
  await this.windowReady();
127
106
 
@@ -130,22 +109,17 @@ class EeApp extends BaseApp {
130
109
  await this._loderPreload();
131
110
 
132
111
  this.selectAppType();
133
-
134
- // DevTools
135
- if (!app.isPackaged && this.config.openDevTools) {
136
- win.webContents.openDevTools();
137
- }
138
112
  }
139
113
 
140
114
  /**
141
115
  * 还原窗口
142
116
  */
143
117
  restoreMainWindow () {
144
- if (this.electron.mainWindow) {
145
- if (this.electron.mainWindow.isMinimized()) {
146
- this.electron.mainWindow.restore();
118
+ if (this.mainWindow) {
119
+ if (this.mainWindow.isMinimized()) {
120
+ this.mainWindow.restore();
147
121
  }
148
- this.electron.mainWindow.show()
122
+ this.mainWindow.show()
149
123
  }
150
124
  }
151
125
 
@@ -172,7 +146,7 @@ class EeApp extends BaseApp {
172
146
 
173
147
  // html模式
174
148
  if (selectMode == 'html') {
175
- if (this.config.env !== 'prod') {
149
+ if (Ps.isDev()) {
176
150
  staticDir = path.join(this.config.homeDir, 'frontend', 'dist');
177
151
  }
178
152
  this.loadLocalWeb('html', staticDir, modeInfo);
@@ -182,7 +156,7 @@ class EeApp extends BaseApp {
182
156
  // 单页应用
183
157
  const protocol = modeInfo.protocol || 'http://';
184
158
  url = protocol + modeInfo.hostname + ':' + modeInfo.port;
185
- if (this.config.env !== 'prod') {
159
+ if (Ps.isDev()) {
186
160
  this.loadMainUrl('spa', url);
187
161
  } else {
188
162
  this.loadLocalWeb('spa');
@@ -239,7 +213,7 @@ class EeApp extends BaseApp {
239
213
  const mainServer = this.config.mainServer;
240
214
  Log.coreLogger.info('[ee-core] [main] Env: %s, Type: %s', this.config.env, type);
241
215
  Log.coreLogger.info('[ee-core] [main] App running at: %s', url);
242
- this.electron.mainWindow.loadURL(url, mainServer.options);
216
+ this.mainWindow.loadURL(url, mainServer.options);
243
217
  }
244
218
 
245
219
  /**
@@ -259,7 +233,7 @@ class EeApp extends BaseApp {
259
233
  // 注册主窗口Contents id
260
234
  const addonsCfg = this.config.addons;
261
235
  if (addonsCfg.window.enable) {
262
- const win = this.electron.mainWindow;
236
+ const win = this.mainWindow;
263
237
  const addonWindow = this.addon.window;
264
238
  addonWindow.registerWCid('main', win.webContents.id);
265
239
  }
package/ee/index.js ADDED
@@ -0,0 +1,30 @@
1
+ const EEApplication = Symbol('Ee#Application');
2
+
3
+ const EE = {
4
+
5
+ /**
6
+ * 兼容1.x版本api
7
+ */
8
+ get Appliaction() {
9
+ const appClass = require('./application');
10
+ return appClass;
11
+ },
12
+
13
+ /**
14
+ * 设置app对象
15
+ */
16
+ set app(appObject) {
17
+ if (!this[EEApplication]) {
18
+ this[EEApplication] = appObject;
19
+ }
20
+ },
21
+
22
+ /**
23
+ * 获取app对象
24
+ */
25
+ get app() {
26
+ return this[EEApplication] || null;
27
+ },
28
+ }
29
+
30
+ module.exports = EE;
@@ -0,0 +1,32 @@
1
+ const Window = require('./window');
2
+ const EEMainWindow = Symbol('Ee#electron#mainWindow');
3
+
4
+ const Electron = {
5
+
6
+ /**
7
+ * 获取 mainWindow
8
+ */
9
+ getMainWindow() {
10
+ if (!this[EEMainWindow]) {
11
+ this[EEMainWindow] = Window.createWindow();
12
+ }
13
+
14
+ return this[EEMainWindow] || null;
15
+ },
16
+
17
+ /**
18
+ * 兼容1.x版本api
19
+ */
20
+ get mainWindow() {
21
+ return this.getMainWindow();
22
+ },
23
+
24
+ /**
25
+ * extra
26
+ */
27
+ extra: {
28
+ closeWindow: false,
29
+ },
30
+ };
31
+
32
+ module.exports = Electron;
@@ -0,0 +1,45 @@
1
+ const {app, BrowserWindow, Menu} = require('electron');
2
+ const Conf = require('../config');
3
+ const Ps = require('../ps');
4
+
5
+ const Window = {
6
+
7
+ /**
8
+ * 创建应用主窗口
9
+ */
10
+ createWindow () {
11
+
12
+ // todo
13
+ // const protocolName = 'eefile';
14
+ // protocol.registerFileProtocol(protocolName, (request, callback) => {
15
+ // const url = request.url.substring(protocolName.length + 3);
16
+ // console.log('[ee-core] [lib/eeApp] registerFileProtocol ----url: ', url);
17
+ // callback({ path: path.normalize(decodeURIComponent(url)) })
18
+ // });
19
+
20
+ const config = Conf.all();
21
+ let win = new BrowserWindow(config.windowsOption);
22
+
23
+ // 菜单显示/隐藏
24
+ if (config.openAppMenu === 'dev-show' && Ps.isProd()) {
25
+ Menu.setApplicationMenu(null);
26
+ } else if (config.openAppMenu === false) {
27
+ Menu.setApplicationMenu(null);
28
+ } else {
29
+ // nothing
30
+ }
31
+
32
+ // DevTools
33
+ if (!app.isPackaged && config.openDevTools) {
34
+ win.webContents.openDevTools({
35
+ mode: 'undocked'
36
+ });
37
+ }
38
+
39
+ return win;
40
+ }
41
+
42
+
43
+ };
44
+
45
+ module.exports = Window;
package/index.js CHANGED
@@ -1,46 +1,45 @@
1
1
  /**
2
2
  * @namespace EeCore
3
3
  */
4
- let app;
4
+
5
+ /**
6
+ * @member {app} EeCore#app
7
+ * @since 1.0.0
8
+ */
9
+ const EE = require('./ee');
5
10
 
6
11
  /**
7
12
  * @member {Controller} EeCore#Controller
8
13
  * @since 1.0.0
9
14
  */
10
- const Controller = require('./module/controller');
15
+ const Controller = require('./controller');
11
16
 
12
17
  /**
13
18
  * @member {Service} EeCore#Service
14
19
  * @since 1.0.0
15
20
  */
16
- const Service = require('./module/service');
21
+ const Service = require('./service');
17
22
 
18
23
  /**
19
24
  * @member {Storage}
20
25
  * @since 1.0.0
21
26
  */
22
- const Storage = require('./module/storage');
27
+ const Storage = require('./storage');
23
28
 
24
29
  /**
25
30
  * @member {Utils}
26
31
  * @since 1.0.0
27
32
  */
28
- const Utils = require('./module/oldUtils');
33
+ const Utils = require('./oldUtils');
29
34
 
30
35
  /**
31
36
  * @member {Socket}
32
37
  * @since 1.0.0
33
38
  */
34
- const Socket = require('./module/socket/io');
39
+ const Socket = require('./socket');
35
40
 
36
41
  module.exports = {
37
- get Appliaction () {
38
- if (app) {
39
- return app;
40
- }
41
- app = require('./module/app/application');
42
- return app;
43
- },
42
+ Appliaction: EE.Appliaction,
44
43
  Controller,
45
44
  Service,
46
45
  Storage,
@@ -1,22 +1,16 @@
1
1
 
2
2
  const is = require('is-type-of');
3
- let Exception;
4
- let Loader;
5
- let Log;
6
- let UtilsCore;
3
+ const Exception = require('ee-core/exception');
4
+ const Loader = require('ee-core/loader');
5
+ const Log = require('ee-core/log');
6
+ const UtilsCore = require('../../core/lib/utils');
7
7
 
8
8
  // 开发环境下,ee-core是soft link
9
- if (__dirname.indexOf("node_modules") == -1) {
10
- Exception = require('../../exception');
11
- Loader = require('../../loader');
12
- Log = require('../../log');
13
- UtilsCore = require('../../core/lib/utils');
14
- } else {
15
- Exception = require('ee-core/module/exception');
16
- Loader = require('ee-core/module/loader');
17
- Log = require('ee-core/module/log');
18
- UtilsCore = require('../../core/lib/utils');
19
- }
9
+ // /node_modules[\\/]electron[\\/]/.test(process.execPath)
10
+ // const Exception = require('../../exception');
11
+ // const Loader = require('../../loader');
12
+ // const Log = require('../../log');
13
+ // const UtilsCore = require('../../core/lib/utils');
20
14
 
21
15
  Exception.start();
22
16
 
@@ -1,22 +1,16 @@
1
1
 
2
2
  const is = require('is-type-of');
3
- let Exception;
4
- let Loader;
5
- let Log;
6
- let UtilsCore;
3
+ const Exception = require('ee-core/exception');
4
+ const Loader = require('ee-core/loader');
5
+ const Log = require('ee-core/log');
6
+ const UtilsCore = require('../../core/lib/utils');
7
7
 
8
8
  // 开发环境下,ee-core是soft link
9
- if (__dirname.indexOf("node_modules") == -1) {
10
- Exception = require('../../exception');
11
- Loader = require('../../loader');
12
- Log = require('../../log');
13
- UtilsCore = require('../../core/lib/utils');
14
- } else {
15
- Exception = require('ee-core/module/exception');
16
- Loader = require('ee-core/module/loader');
17
- Log = require('ee-core/module/log');
18
- UtilsCore = require('../../core/lib/utils');
19
- }
9
+ // /node_modules[\\/]electron[\\/]/.test(process.execPath)
10
+ // const Exception = require('../../exception');
11
+ // const Loader = require('../../loader');
12
+ // const Log = require('../../log');
13
+ // const UtilsCore = require('../../core/lib/utils');
20
14
 
21
15
  Exception.start();
22
16
 
@@ -16,6 +16,4 @@ const message = {
16
16
 
17
17
  };
18
18
 
19
-
20
-
21
19
  module.exports = message;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ee-core",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.7",
4
4
  "description": "ee core",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "author": "",
10
10
  "license": "ISC",
11
11
  "bin": {
12
- "ee-core": "./module/bin/tools.js"
12
+ "ee-core": "./bin/tools.js"
13
13
  },
14
14
  "dependencies": {
15
15
  "agentkeepalive": "^4.2.0",
@@ -19,8 +19,6 @@
19
19
  "depd": "^2.0.0",
20
20
  "egg-errors": "^2.3.0",
21
21
  "egg-logger": "^2.7.1",
22
- "electron-is": "^3.0.0",
23
- "electron-updater": "^4.6.1",
24
22
  "extend2": "^1.0.1",
25
23
  "fs-extra": "^10.0.0",
26
24
  "get-port": "^5.1.1",
@@ -35,7 +33,7 @@
35
33
  "koa2-cors": "^2.0.6",
36
34
  "lodash": "^4.17.21",
37
35
  "mkdirp": "^2.1.3",
38
- "path-to-regexp": "^6.2.0",
36
+ "semver": "^7.3.8",
39
37
  "serialize-javascript": "^6.0.1",
40
38
  "socket.io": "^4.4.1",
41
39
  "socket.io-client": "^4.4.1",
@@ -1,5 +1,5 @@
1
1
  const path = require('path');
2
- const eis = require('electron-is');
2
+ const eis = require('../utils/is');
3
3
 
4
4
  /**
5
5
  * 当前进程的所有env
@@ -20,6 +20,13 @@ exports.env = function() {
20
20
  */
21
21
  exports.getEnv = this.env
22
22
 
23
+ /**
24
+ * 是否生产环境
25
+ */
26
+ exports.isProd = function() {
27
+ return (process.env.EE_SERVER_ENV === 'prod');
28
+ }
29
+
23
30
  /**
24
31
  * 是否为开发环境
25
32
  */
@@ -182,21 +189,21 @@ exports.getUserHomeDir = function () {
182
189
  * 获取主进程端口
183
190
  */
184
191
  exports.getMainPort = function () {
185
- return process.env.EE_MAIN_PORT;
192
+ return parseInt(process.env.EE_MAIN_PORT) || 0;
186
193
  }
187
194
 
188
195
  /**
189
196
  * 获取内置socket端口
190
197
  */
191
198
  exports.getSocketPort = function () {
192
- return process.env.EE_SOCKET_PORT;
199
+ return parseInt(process.env.EE_SOCKET_PORT) || 0;
193
200
  }
194
201
 
195
202
  /**
196
203
  * 获取内置http端口
197
204
  */
198
205
  exports.getHttpPort = function () {
199
- return process.env.EE_HTTP_PORT;
206
+ return parseInt(process.env.EE_HTTP_PORT) || 0;
200
207
  }
201
208
 
202
209
  /**