ee-core 2.11.1 → 4.0.0-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.
Files changed (96) hide show
  1. package/app/application.js +31 -0
  2. package/app/boot.js +81 -0
  3. package/app/dir.js +27 -0
  4. package/app/events.js +56 -0
  5. package/app/index.js +7 -0
  6. package/config/config_loader.js +66 -0
  7. package/config/default_config.js +110 -0
  8. package/config/index.js +21 -83
  9. package/const/channel.js +26 -16
  10. package/const/index.js +0 -4
  11. package/controller/controller_loader.js +78 -0
  12. package/controller/index.js +18 -19
  13. package/core/index.js +6 -5
  14. package/core/{lib/loader → loader}/file_loader.js +39 -156
  15. package/core/utils/index.js +83 -0
  16. package/core/{lib/utils → utils}/timing.js +3 -2
  17. package/cross/cross.js +152 -0
  18. package/cross/index.js +6 -181
  19. package/cross/spawnProcess.js +34 -51
  20. package/electron/app/index.js +38 -54
  21. package/electron/index.js +13 -17
  22. package/electron/window/index.js +260 -65
  23. package/exception/index.js +34 -32
  24. package/html/index.js +7 -10
  25. package/index.js +4 -52
  26. package/jobs/child/app.js +9 -9
  27. package/jobs/child/forkProcess.js +29 -45
  28. package/jobs/child/index.js +13 -10
  29. package/jobs/child-pool/index.js +13 -11
  30. package/jobs/index.js +2 -4
  31. package/loader/index.js +91 -144
  32. package/log/index.js +74 -57
  33. package/log/logger.js +76 -84
  34. package/message/childMessage.js +12 -13
  35. package/message/index.js +7 -16
  36. package/package.json +2 -2
  37. package/ps/index.js +137 -223
  38. package/socket/httpServer.js +46 -43
  39. package/socket/index.js +52 -69
  40. package/socket/ipcServer.js +80 -94
  41. package/socket/socketServer.js +31 -24
  42. package/storage/index.js +5 -37
  43. package/storage/sqliteStorage.js +18 -18
  44. package/utils/extend.js +10 -5
  45. package/utils/helper.js +38 -42
  46. package/utils/index.js +40 -23
  47. package/utils/ip.js +5 -45
  48. package/utils/is.js +107 -141
  49. package/utils/json.js +15 -7
  50. package/utils/pargv.js +5 -1
  51. package/utils/{get-port → port}/index.js +4 -26
  52. package/utils/wrap.js +8 -3
  53. package/addon/index.js +0 -35
  54. package/addon/window/index.js +0 -99
  55. package/bin/tools.js +0 -8
  56. package/config/cache.js +0 -42
  57. package/config/config.default.js +0 -331
  58. package/controller/baseContextClass.js +0 -25
  59. package/core/lib/ee.js +0 -216
  60. package/core/lib/loader/context_loader.js +0 -106
  61. package/core/lib/loader/ee_loader.js +0 -435
  62. package/core/lib/loader/mixin/addon.js +0 -32
  63. package/core/lib/loader/mixin/config.js +0 -130
  64. package/core/lib/loader/mixin/controller.js +0 -125
  65. package/core/lib/loader/mixin/service.js +0 -28
  66. package/core/lib/utils/base_context_class.js +0 -34
  67. package/core/lib/utils/function.js +0 -30
  68. package/core/lib/utils/index.js +0 -133
  69. package/core/lib/utils/sequencify.js +0 -59
  70. package/ee/appLoader.js +0 -48
  71. package/ee/application.js +0 -100
  72. package/ee/baseApp.js +0 -104
  73. package/ee/eeApp.js +0 -409
  74. package/ee/index.js +0 -58
  75. package/electron/window/winState.js +0 -186
  76. package/httpclient/index.js +0 -161
  77. package/jobs/baseJobClass.js +0 -16
  78. package/jobs/renderer/index.js +0 -141
  79. package/jobs/renderer/loadView.js +0 -41
  80. package/jobs/unification.js +0 -64
  81. package/main/index.js +0 -57
  82. package/old-utils/index.js +0 -91
  83. package/services/baseContextClass.js +0 -24
  84. package/services/index.js +0 -41
  85. package/socket/io.js +0 -28
  86. package/storage/jsondb/adapters/Base.js +0 -23
  87. package/storage/jsondb/adapters/FileSync.js +0 -64
  88. package/storage/jsondb/main.js +0 -55
  89. package/storage/jsondbStorage.js +0 -196
  90. package/utils/co.js +0 -237
  91. package/utils/copyto.js +0 -161
  92. package/utils/depd/index.js +0 -538
  93. package/utils/depd/lib/browser/index.js +0 -77
  94. package/utils/get-port/index.d.ts +0 -64
  95. package/utils/time/index.js +0 -20
  96. package/utils/time/ms.js +0 -162
package/utils/json.js CHANGED
@@ -2,7 +2,7 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const mkdirp = require('mkdirp');
4
4
 
5
- exports.strictParse = function (str) {
5
+ function strictParse(str) {
6
6
  const obj = JSON.parse(str);
7
7
  if (!obj || typeof obj !== 'object') {
8
8
  throw new Error('JSON string is not object');
@@ -10,14 +10,14 @@ exports.strictParse = function (str) {
10
10
  return obj;
11
11
  };
12
12
 
13
- exports.readSync = function(filepath) {
13
+ function readSync(filepath) {
14
14
  if (!fs.existsSync(filepath)) {
15
15
  throw new Error(filepath + ' is not found');
16
16
  }
17
17
  return JSON.parse(fs.readFileSync(filepath));
18
18
  };
19
19
 
20
- exports.writeSync = function(filepath, str, options) {
20
+ function writeSync(filepath, str, options) {
21
21
  options = options || {};
22
22
  if (!('space' in options)) {
23
23
  options.space = 2;
@@ -31,7 +31,7 @@ exports.writeSync = function(filepath, str, options) {
31
31
  fs.writeFileSync(filepath, str);
32
32
  };
33
33
 
34
- exports.read = function(filepath) {
34
+ function read(filepath) {
35
35
  return fs.stat(filepath)
36
36
  .then(function(stats) {
37
37
  if (!stats.isFile()) {
@@ -44,7 +44,7 @@ exports.read = function(filepath) {
44
44
  });
45
45
  };
46
46
 
47
- exports.write = function(filepath, str, options) {
47
+ function write(filepath, str, options) {
48
48
  options = options || {};
49
49
  if (!('space' in options)) {
50
50
  options.space = 2;
@@ -54,13 +54,13 @@ exports.write = function(filepath, str, options) {
54
54
  str = JSON.stringify(str, options.replacer, options.space) + '\n';
55
55
  }
56
56
 
57
- return mkdir(path.dirname(filepath))
57
+ return _mkdir(path.dirname(filepath))
58
58
  .then(function() {
59
59
  return fs.writeFile(filepath, str);
60
60
  });
61
61
  };
62
62
 
63
- function mkdir(dir) {
63
+ function _mkdir(dir) {
64
64
  return new Promise(function(resolve, reject) {
65
65
  mkdirp(dir, function(err) {
66
66
  if (err) {
@@ -70,3 +70,11 @@ function mkdir(dir) {
70
70
  });
71
71
  });
72
72
  }
73
+
74
+ module.exports = {
75
+ strictParse,
76
+ readSync,
77
+ writeSync,
78
+ read,
79
+ write
80
+ }
package/utils/pargv.js CHANGED
@@ -20,7 +20,7 @@ function isConstructorOrProto(obj, key) {
20
20
  return (key === 'constructor' && typeof obj[key] === 'function') || key === '__proto__';
21
21
  }
22
22
 
23
- module.exports = function (args, opts) {
23
+ function parseArgv(args, opts) {
24
24
  if (!opts) { opts = {}; }
25
25
 
26
26
  var flags = {
@@ -261,3 +261,7 @@ module.exports = function (args, opts) {
261
261
 
262
262
  return argv;
263
263
  };
264
+
265
+ module.exports = {
266
+ parseArgv
267
+ }
@@ -77,7 +77,7 @@ const portCheckSequence = function * (ports) {
77
77
  yield 0; // Fall back to 0 if anything else failed
78
78
  };
79
79
 
80
- module.exports = async options => {
80
+ async function getPort(options) {
81
81
  let ports;
82
82
 
83
83
  if (options) {
@@ -121,28 +121,6 @@ module.exports = async options => {
121
121
  throw new Error('No available ports found');
122
122
  };
123
123
 
124
- module.exports.makeRange = (from, to) => {
125
- if (!Number.isInteger(from) || !Number.isInteger(to)) {
126
- throw new TypeError('`from` and `to` must be integer numbers');
127
- }
128
-
129
- if (from < 1024 || from > 65535) {
130
- throw new RangeError('`from` must be between 1024 and 65535');
131
- }
132
-
133
- if (to < 1024 || to > 65536) {
134
- throw new RangeError('`to` must be between 1024 and 65536');
135
- }
136
-
137
- if (to < from) {
138
- throw new RangeError('`to` must be greater than or equal to `from`');
139
- }
140
-
141
- const generator = function * (from, to) {
142
- for (let port = from; port <= to; port++) {
143
- yield port;
144
- }
145
- };
146
-
147
- return generator(from, to);
148
- };
124
+ module.exports = {
125
+ getPort
126
+ }
package/utils/wrap.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const assert = require('assert');
2
2
  const is = require('is-type-of');
3
3
 
4
- exports.getProperties = (filepath, { caseStyle }) => {
4
+ function getProperties(filepath, { caseStyle }) {
5
5
  // if caseStyle is function, return the result of function
6
6
  if (is.function(caseStyle)) {
7
7
  const result = caseStyle(filepath);
@@ -9,10 +9,10 @@ exports.getProperties = (filepath, { caseStyle }) => {
9
9
  return result;
10
10
  }
11
11
  // use default camelize
12
- return this.defaultCamelize(filepath, caseStyle);
12
+ return defaultCamelize(filepath, caseStyle);
13
13
  }
14
14
 
15
- exports.defaultCamelize = (filepath, caseStyle) => {
15
+ function defaultCamelize(filepath, caseStyle) {
16
16
  const properties = filepath.substring(0, filepath.lastIndexOf('.')).split('/');
17
17
  return properties.map(property => {
18
18
  if (!/^[a-z][a-z0-9_-]*$/i.test(property)) {
@@ -33,4 +33,9 @@ exports.defaultCamelize = (filepath, caseStyle) => {
33
33
  }
34
34
  return first + property.substring(1);
35
35
  });
36
+ }
37
+
38
+ module.exports = {
39
+ getProperties,
40
+ defaultCamelize,
36
41
  }
package/addon/index.js DELETED
@@ -1,35 +0,0 @@
1
- const EE = require('../ee');
2
-
3
- const Addon = {
4
-
5
- /**
6
- * 获取 all addon instances
7
- */
8
- all() {
9
- const { CoreApp } = EE;
10
- if (!CoreApp) {
11
- throw new Error('An unknown error or Addons cannot be used by the jobs!');
12
- }
13
-
14
- const instances = CoreApp.addon || null;
15
- if (!instances) {
16
- throw new Error('Addons not exists or do not call directly at the top!');
17
- };
18
- return instances;
19
- },
20
-
21
- /**
22
- * 获取 addon instance
23
- */
24
- get(name) {
25
- const instances = this.all();
26
- const instance = instances[name] || null;
27
- if (!instance) {
28
- throw new Error(`Addon class '${name}' not exists or do not call directly at the top!`);
29
- };
30
- return instance;
31
- },
32
-
33
- };
34
-
35
- module.exports = Addon;
@@ -1,99 +0,0 @@
1
- const { BrowserWindow } = require('electron');
2
- const extend = require('../../utils/extend');
3
-
4
- /**
5
- * 窗口插件
6
- * @class
7
- */
8
- class WinAddon {
9
-
10
- constructor(app) {
11
- this.app = app;
12
- this.windowContentsIdMap = {};
13
- }
14
-
15
- /**
16
- * create window
17
- *
18
- * @function
19
- * @since 1.0.0
20
- */
21
- create(name, opt) {
22
-
23
- // todo 判断name是否唯一
24
- // if (this.windowContentsIdMap.hasOwnProperty(name)) {
25
- // throw new Error(`[addon] [window] Name: ${name} already exists!`);
26
- // }
27
-
28
- const options = extend(true, {}, {
29
- x: 10,
30
- y: 10,
31
- width: 980,
32
- height: 650,
33
- webPreferences: {
34
- contextIsolation: false,
35
- nodeIntegration: true,
36
- },
37
- }, opt);
38
- const win = new BrowserWindow(options)
39
-
40
- const winContentsId = win.webContents.id;
41
- win.webContents.on('did-finish-load', () => {
42
- this.registerWCid(name, winContentsId);
43
- })
44
-
45
- win.webContents.on('destroyed', () => {
46
- this.removeWCid(name);
47
- })
48
-
49
- win.webContents.on('render-process-gone', (event, details) => {
50
- this.removeWCid(name);
51
- })
52
-
53
- return win;
54
- }
55
-
56
- /**
57
- * 获取窗口Contents id
58
- *
59
- * @function
60
- * @since 1.0.0
61
- */
62
- getWCid(name) {
63
- const id = this.windowContentsIdMap[name] || null;
64
- return id;
65
- }
66
-
67
- /**
68
- * 获取主窗口Contents id
69
- *
70
- * @function
71
- * @since 1.0.0
72
- */
73
- getMWCid() {
74
- const id = this.windowContentsIdMap['main'] || null;
75
- return id;
76
- }
77
-
78
- /**
79
- * 注册窗口Contents id
80
- *
81
- * @function
82
- * @since 1.0.0
83
- */
84
- registerWCid(name, id) {
85
- this.windowContentsIdMap[name] = id;
86
- }
87
-
88
- /**
89
- * 销毁窗口Contents id
90
- *
91
- * @function
92
- * @since 1.0.0
93
- */
94
- removeWCid(name) {
95
- delete this.windowContentsIdMap[name];
96
- }
97
- }
98
-
99
- module.exports = WinAddon;
package/bin/tools.js DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const chalk = require('chalk');
4
-
5
- let tip = chalk.bgYellow('Warning') + ' please use ' + chalk.blue('ee-bin') + ', See: ';
6
- tip += chalk.underline('https://www.kaka996.com/pages/e1816f/');
7
-
8
- console.log(tip);
package/config/cache.js DELETED
@@ -1,42 +0,0 @@
1
- const EE = require('../ee');
2
-
3
- const conf = {
4
-
5
- /**
6
- * 获取 内存中的config
7
- */
8
- _getConfig(withError = true) {
9
- const { CoreApp } = EE;
10
- if (!CoreApp && withError) {
11
- throw new Error(`[ee-core] [config] Frame initialization is not complete !`);
12
- }
13
- if (!CoreApp) {
14
- return null;
15
- }
16
-
17
- return CoreApp.config;
18
- },
19
-
20
- /**
21
- * all
22
- */
23
- all(withError = true) {
24
- return this._getConfig(withError);
25
- },
26
-
27
- /**
28
- * getValue
29
- */
30
- getValue(key) {
31
- const v = this._objectGet(this._getConfig(), key);
32
- return v;
33
- },
34
-
35
- _objectGet(object, path, defaultValue) {
36
- const pathParts = Array.isArray(path) ? path : path.split('.');
37
- const value = pathParts.reduce((obj, key) => obj && key in obj ? obj[key] : undefined, object);
38
- return value === undefined ? defaultValue : value;
39
- }
40
- };
41
-
42
- module.exports = conf;
@@ -1,331 +0,0 @@
1
- const path = require('path');
2
-
3
- /**
4
- * The configuration of ee application, can be access by `app.config`
5
- * @class Config
6
- * @since 1.0.0
7
- */
8
-
9
- module.exports = appInfo => {
10
-
11
- const config = {
12
-
13
- /**
14
- * The environment of ee
15
- * @member {String} Config#env
16
- * @see {appInfo#env}
17
- * @since 1.0.0
18
- */
19
- env: appInfo.env,
20
-
21
- /**
22
- * The name of the application
23
- * @member {String} Config#name
24
- * @see {appInfo#name}
25
- * @since 1.0.0
26
- */
27
- name: appInfo.name,
28
-
29
- /**
30
- * The current directory of the application
31
- * @member {String} Config#baseDir
32
- * @see {appInfo#baseDir}
33
- * @since 1.0.0
34
- */
35
- baseDir: appInfo.baseDir,
36
-
37
- /**
38
- * The current HOME directory
39
- * @member {String} Config#HOME
40
- * @see {appInfo#HOME}
41
- * @since 1.0.0
42
- */
43
- HOME: appInfo.home,
44
-
45
- /**
46
- * The directory of server running. You can find `application_config.json` under it that is dumpped from `app.config`.
47
- * @member {String} Config#rundir
48
- * @default
49
- * @since 1.0.0
50
- */
51
- rundir: path.join(appInfo.baseDir, 'run'),
52
-
53
- /**
54
- * dump config
55
- *
56
- * It will ignore special keys when dumpConfig
57
- *
58
- * @member Config#dump
59
- * @property {Set} ignore - keys to ignore
60
- */
61
- dump: {
62
- ignore: new Set([
63
- 'pass', 'pwd', 'passd', 'passwd', 'password', 'keys', 'masterKey', 'accessKey',
64
- // ignore any key contains "secret" keyword
65
- /secret/i,
66
- ]),
67
- },
68
-
69
- /**
70
- * application home directory
71
- * @member {String} Config#homeDir
72
- * @default
73
- * @since 1.0.0
74
- */
75
- homeDir: appInfo.home,
76
-
77
- /**
78
- * application data & logs directory by env
79
- * @member {String} Config#root
80
- * @default
81
- * @since 1.0.0
82
- */
83
- root: appInfo.root,
84
-
85
- /**
86
- * application data directory
87
- * @member {String} Config#appUserDataDir
88
- * @default
89
- * @since 1.0.0
90
- */
91
- appUserDataDir: appInfo.appUserDataDir,
92
-
93
- /**
94
- * system user home dir
95
- * @member {String} Config#userHome
96
- */
97
- userHome: appInfo.userHome,
98
-
99
- /**
100
- * application version
101
- * @member {String} Config#appVersion
102
- */
103
- appVersion: appInfo.appVersion,
104
-
105
- /**
106
- * application package status
107
- * @member {boolean} Config#isPackaged
108
- */
109
- isPackaged: appInfo.isPackaged,
110
-
111
- /**
112
- * application exec file dir
113
- * @member {String} Config#execDir
114
- */
115
- execDir: appInfo.execDir
116
- };
117
-
118
- /**
119
- * logger options
120
- * @member Config#logger
121
- * @property {String} dir - directory of log files
122
- * @property {String} encoding - log file encoding, defaults to utf8
123
- * @property {String} level - default log level, could be: DEBUG, INFO, WARN, ERROR or NONE, defaults to INFO in production
124
- * @property {String} consoleLevel - log level of stdout, defaults to INFO in local serverEnv, defaults to WARN in unittest, defaults to NONE elsewise
125
- * @property {Boolean} disableConsoleAfterReady - disable logger console after app ready. defaults to `false` on local and unittest env, others is `true`.
126
- * @property {Boolean} outputJSON - log as JSON or not, defaults to false
127
- * @property {Boolean} buffer - if enabled, flush logs to disk at a certain frequency to improve performance, defaults to true
128
- * @property {String} errorLogName - file name of errorLogger
129
- * @property {String} coreLogName - file name of coreLogger
130
- * @property {String} agentLogName - file name of agent worker log
131
- * @property {Object} coreLogger - custom config of coreLogger
132
- * @property {Boolean} allowDebugAtProd - allow debug log at prod, defaults to false
133
- * @property {Boolean} enablePerformanceTimer - using performance.now() timer instead of Date.now() for more more precise milliseconds, defaults to false. e.g.: logger will set 1.456ms instead of 1ms.
134
- */
135
- config.logger = {
136
- type: 'application',
137
- dir: path.join(appInfo.root, 'logs'),
138
- encoding: 'utf8',
139
- env: appInfo.env,
140
- level: 'INFO',
141
- consoleLevel: 'INFO',
142
- disableConsoleAfterReady: appInfo.env !== 'local' && appInfo.env !== 'unittest',
143
- outputJSON: false,
144
- buffer: true,
145
- appLogName: `ee.log`,
146
- coreLogName: 'ee-core.log',
147
- agentLogName: 'ee-agent.log',
148
- errorLogName: `ee-error.log`,
149
- coreLogger: {},
150
- allowDebugAtProd: false,
151
- enablePerformanceTimer: false,
152
- rotator: 'none',
153
- };
154
-
155
- /**
156
- * customLogger options
157
- * @member Config#customLogger
158
- *
159
- */
160
- config.customLogger = {}
161
-
162
- /**
163
- * The option for httpclient
164
- * @member Config#httpclient
165
- * @property {Boolean} enableDNSCache - Enable DNS lookup from local cache or not, default is false.
166
- * @property {Boolean} dnsCacheLookupInterval - minimum interval of DNS query on the same hostname (default 10s).
167
- *
168
- * @property {Number} request.timeout - httpclient request default timeout, default is 5000 ms.
169
- *
170
- * @property {Boolean} httpAgent.keepAlive - Enable http agent keepalive or not, default is true
171
- * @property {Number} httpAgent.freeSocketTimeout - http agent socket keepalive max free time, default is 4000 ms.
172
- * @property {Number} httpAgent.maxSockets - http agent max socket number of one host, default is `Number.MAX_SAFE_INTEGER` @ses https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
173
- * @property {Number} httpAgent.maxFreeSockets - http agent max free socket number of one host, default is 256.
174
- *
175
- * @property {Boolean} httpsAgent.keepAlive - Enable https agent keepalive or not, default is true
176
- * @property {Number} httpsAgent.freeSocketTimeout - httpss agent socket keepalive max free time, default is 4000 ms.
177
- * @property {Number} httpsAgent.maxSockets - https agent max socket number of one host, default is `Number.MAX_SAFE_INTEGER` @ses https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER
178
- * @property {Number} httpsAgent.maxFreeSockets - https agent max free socket number of one host, default is 256.
179
- */
180
- config.httpclient = {
181
- enableDNSCache: false,
182
- dnsCacheLookupInterval: 10000,
183
- dnsCacheMaxLength: 1000,
184
- request: {
185
- timeout: 5000,
186
- },
187
- httpAgent: {
188
- keepAlive: true,
189
- freeSocketTimeout: 4000,
190
- maxSockets: Number.MAX_SAFE_INTEGER,
191
- maxFreeSockets: 256,
192
- },
193
- httpsAgent: {
194
- keepAlive: true,
195
- freeSocketTimeout: 4000,
196
- maxSockets: Number.MAX_SAFE_INTEGER,
197
- maxFreeSockets: 256,
198
- },
199
- };
200
-
201
- /**
202
- * 应用模式配置
203
- */
204
- config.developmentMode = {
205
- default: 'vue',
206
- mode: {
207
- vue: {
208
- protocol: 'http://',
209
- hostname: 'localhost',
210
- port: 8080
211
- },
212
- react: {
213
- protocol: 'http://',
214
- hostname: 'localhost',
215
- port: 3000
216
- },
217
- html: {
218
- protocol: 'http://',
219
- hostname: 'localhost',
220
- indexPage: 'index.html'
221
- },
222
- }
223
- };
224
-
225
- /* 内置socket服务 */
226
- config.socketServer = {
227
- enable: false, // 是否启用
228
- port: 7070, // 默认端口(如果端口被使用,则随机获取一个)
229
- path: "/socket.io/", // 路径名称
230
- connectTimeout: 45000, // 客户端连接超时时间
231
- pingTimeout: 30000, // 心跳检测超时时间
232
- pingInterval: 25000, // 心跳检测间隔
233
- maxHttpBufferSize: 1e8, // 每条消息的数据大小 1M
234
- transports: ["polling", "websocket"], // http轮询和websocket
235
- cors: {
236
- origin: true, // http协议时,要设置跨域 类型 Boolean String RegExp Array Function
237
- }
238
- };
239
-
240
- /* 内置http服务 */
241
- config.httpServer = {
242
- enable: false, // 是否启用
243
- https: {
244
- enable: false,
245
- key: '',
246
- cert: ''
247
- },
248
- protocol: 'http://',
249
- host: 'localhost',
250
- port: 7071, // 默认端口(如果端口被使用,则随机获取一个)
251
- cors: {
252
- origin: "*"
253
- },
254
- body: {
255
- multipart: true, // 文件类型
256
- },
257
- filterRequest: {
258
- uris: [],
259
- returnData: ''
260
- }
261
- };
262
-
263
- /* 主进程加载的地址 */
264
- config.mainServer = {
265
- protocol: 'file://', // http:// | https:// | file://
266
- indexPath: '/public/dist/index.html',
267
- host: 'localhost',
268
- port: 7072, // 默认端口(如果端口被使用,则随机获取一个)
269
- open: false, // 是否开放0.0.0.0,默认关闭
270
- options: {},
271
- ssl: {
272
- key: '',
273
- cert: ''
274
- }
275
- };
276
-
277
- /**
278
- * 应用程序顶部菜单
279
- * boolean | string
280
- * true, false, 'dev-show'(dev环境显示,prod环境隐藏)
281
- */
282
- config.openAppMenu = true;
283
-
284
- /**
285
- * 硬件加速
286
- */
287
- config.hardGpu = {
288
- enable: true
289
- };
290
-
291
- /**
292
- * TODO storage
293
- */
294
- config.storage = {
295
- dir: path.join(appInfo.root, 'data'),
296
- };
297
-
298
- /**
299
- * addons
300
- */
301
- config.addons = {
302
- window: {
303
- enable: true,
304
- }
305
- };
306
-
307
- /**
308
- * 异常捕获
309
- */
310
- config.exception = {
311
- mainExit: false,
312
- childExit: true,
313
- rendererExit: true,
314
- };
315
-
316
- /**
317
- * Cross-language service
318
- * 跨语言服务
319
- * 例如:执行go的二进制程序
320
- */
321
- config.cross = {};
322
-
323
- /**
324
- * jobs
325
- */
326
- config.jobs = {
327
- messageLog: true
328
- };
329
-
330
- return config;
331
- };
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * BaseContextClass is a base class that can be extended,
5
- * it's instantiated in context level,
6
- */
7
- class BaseContextClass {
8
-
9
- /**
10
- * @class
11
- * @param {Context} ctx - context instance
12
- * @since 1.1.0
13
- */
14
- constructor(ctx) {
15
-
16
- // todo 兼容旧版本,后续废弃ctx
17
- if (typeof ctx === 'object') {
18
- this.app = ctx;
19
- this.config = ctx.config;
20
- this.service = ctx.service;
21
- }
22
- }
23
- }
24
-
25
- module.exports = BaseContextClass;