ee-core 2.0.0-beta.3 → 2.0.0-beta.6
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/addon/index.js +30 -0
- package/config/config.default.js +2 -3
- package/config/index.js +54 -0
- package/const/channel.js +9 -0
- package/{module/const → const}/index.js +1 -5
- package/controller/index.js +34 -0
- package/core/index.js +0 -2
- package/core/lib/ee.js +0 -2
- package/core/lib/loader/ee_loader.js +2 -2
- package/core/lib/loader/file_loader.js +1 -0
- package/{lib → ee}/application.js +2 -2
- package/{lib → ee}/baseApp.js +5 -4
- package/{lib → ee}/eeApp.js +21 -47
- package/ee/index.js +30 -0
- package/electron/index.js +32 -0
- package/electron/window.js +45 -0
- package/exception/index.js +85 -0
- package/{module/httpclient → httpclient}/index.js +2 -2
- package/index.js +8 -10
- package/jobs/baseJobClass.js +16 -0
- package/jobs/child/app.js +63 -0
- package/jobs/child/forkProcess.js +61 -0
- package/jobs/child/index.js +78 -0
- package/jobs/childPool/app.js +68 -0
- package/{module/jobs/child → jobs/childPool}/forkProcess.js +15 -16
- package/{module/jobs/child → jobs/childPool}/index.js +27 -17
- package/{module/jobs/child → jobs/childPool}/pool.js +3 -3
- package/{module/jobs → jobs}/renderer/loadView.js +1 -1
- package/{module/jobs → jobs}/unification.js +1 -1
- package/{module/loader → loader}/index.js +36 -14
- package/{module/log → log}/logger.js +1 -1
- package/message/childMessage.js +31 -0
- package/{module/message → message}/index.js +2 -11
- package/{module/utils → oldUtils}/index.js +25 -5
- package/package.json +2 -1
- package/{module/utils/ps.js → ps/index.js} +30 -3
- package/service/index.js +34 -0
- package/{module/socket → socket}/httpServer.js +12 -18
- package/socket/index.js +82 -0
- package/{module/socket → socket}/io.js +6 -2
- package/{module/socket → socket}/ipcServer.js +2 -4
- package/socket/socketServer.js +66 -0
- package/{module/storage → storage}/jsondbStorage.js +38 -1
- package/{module/storage → storage}/sqliteStorage.js +1 -1
- package/tools/encrypt.js +1 -1
- package/{module/utils → utils}/helper.js +0 -1
- package/utils/index.js +7 -27
- package/module/exception/index.js +0 -16
- package/module/jobs/child/app.js +0 -43
- package/module/message/childMessage.js +0 -63
- package/module/message/ipcMain.js +0 -160
- package/module/message/ipcRender.js +0 -0
- package/module/message/manager.js +0 -0
- package/module/message/messenger.js +0 -0
- package/module/socket/socketClient.js +0 -49
- package/module/socket/socketServer.js +0 -76
- package/module/socket/start.js +0 -22
- /package/{lib → ee}/appLoader.js +0 -0
- /package/{module/jobs → jobs}/index.js +0 -0
- /package/{module/jobs → jobs}/renderer/index.js +0 -0
- /package/{module/log → log}/index.js +0 -0
- /package/{module/storage → storage}/index.js +0 -0
- /package/{module/storage → storage}/jsondb/adapters/Base.js +0 -0
- /package/{module/storage → storage}/jsondb/adapters/FileSync.js +0 -0
- /package/{module/storage → storage}/jsondb/main.js +0 -0
- /package/{module/utils → utils}/copyto.js +0 -0
- /package/{module/utils → utils}/json.js +0 -0
- /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;
|
package/config/config.default.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
1
|
const path = require('path');
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -222,7 +221,7 @@ module.exports = appInfo => {
|
|
|
222
221
|
cert: ''
|
|
223
222
|
},
|
|
224
223
|
protocol: 'http://',
|
|
225
|
-
host: '
|
|
224
|
+
host: 'localhost',
|
|
226
225
|
port: 7071, // 默认端口(如果端口被使用,则随机获取一个)
|
|
227
226
|
cors: {
|
|
228
227
|
origin: "*"
|
|
@@ -239,7 +238,7 @@ module.exports = appInfo => {
|
|
|
239
238
|
/* 主进程加载的地址 */
|
|
240
239
|
config.mainServer = {
|
|
241
240
|
protocol: 'http://',
|
|
242
|
-
host: '
|
|
241
|
+
host: 'localhost',
|
|
243
242
|
port: 7072, // 默认端口(如果端口被使用,则随机获取一个)
|
|
244
243
|
options: {},
|
|
245
244
|
ssl: {
|
package/config/index.js
ADDED
|
@@ -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;
|
package/const/channel.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* BaseContextClass is a base class that can be extended,
|
|
5
|
+
* it's instantiated in context level,
|
|
6
|
+
* {@link Helper}, {@link Service} is extending it.
|
|
7
|
+
*/
|
|
8
|
+
class BaseContextClass {
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @class
|
|
12
|
+
* @param {Context} ctx - context instance
|
|
13
|
+
* @since 1.0.0
|
|
14
|
+
*/
|
|
15
|
+
constructor(ctx) {
|
|
16
|
+
/**
|
|
17
|
+
* @member {Application} BaseContextClass#app
|
|
18
|
+
* @since 1.0.0
|
|
19
|
+
*/
|
|
20
|
+
this.app = ctx;
|
|
21
|
+
/**
|
|
22
|
+
* @member {Config} BaseContextClass#config
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
*/
|
|
25
|
+
this.config = ctx.config;
|
|
26
|
+
/**
|
|
27
|
+
* @member {Service} BaseContextClass#service
|
|
28
|
+
* @since 1.0.0
|
|
29
|
+
*/
|
|
30
|
+
this.service = ctx.service;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
module.exports = BaseContextClass;
|
package/core/index.js
CHANGED
package/core/lib/ee.js
CHANGED
|
@@ -9,7 +9,7 @@ const FileLoader = require('./file_loader');
|
|
|
9
9
|
const ContextLoader = require('./context_loader');
|
|
10
10
|
const Utils = require('../utils');
|
|
11
11
|
const Timing = require('../utils/timing');
|
|
12
|
-
const Ps = require('../../../
|
|
12
|
+
const Ps = require('../../../ps');
|
|
13
13
|
|
|
14
14
|
const REQUIRE_COUNT = Symbol('EeLoader#requireCount');
|
|
15
15
|
|
|
@@ -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,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const Exception = require('../exception');
|
|
1
2
|
const {app} = require('electron');
|
|
2
3
|
const path = require('path');
|
|
3
4
|
const debug = require('debug')('ee-core:Appliaction');
|
|
@@ -6,6 +7,7 @@ const EeApp = require('./eeApp');
|
|
|
6
7
|
|
|
7
8
|
class Appliaction extends EeApp {
|
|
8
9
|
constructor() {
|
|
10
|
+
Exception.start();
|
|
9
11
|
const { env } = process;
|
|
10
12
|
let options = {
|
|
11
13
|
env: 'prod',
|
|
@@ -80,8 +82,6 @@ class Appliaction extends EeApp {
|
|
|
80
82
|
await this.ready();
|
|
81
83
|
|
|
82
84
|
await this.createElectronApp();
|
|
83
|
-
|
|
84
|
-
await this.catchLog();
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
|
package/{lib → ee}/baseApp.js
RENAMED
|
@@ -3,11 +3,12 @@ const EE_PATH = Symbol.for('ee#eePath');
|
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const EE_LOADER = Symbol.for('ee#loader');
|
|
5
5
|
const AppLoader = require('./appLoader');
|
|
6
|
-
const HttpClient = require('../
|
|
6
|
+
const HttpClient = require('../httpclient');
|
|
7
7
|
const HTTPCLIENT = Symbol('EeApplication#httpclient');
|
|
8
8
|
const LOGGERS = Symbol('EeApplication#loggers');
|
|
9
|
-
const Log = require('../
|
|
10
|
-
const Storage = require('../
|
|
9
|
+
const Log = require('../log');
|
|
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
|
-
|
|
21
|
+
Conf.setAll(this.config);
|
|
21
22
|
|
|
22
23
|
this.loader.load();
|
|
23
24
|
|
package/{lib → ee}/eeApp.js
RENAMED
|
@@ -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
|
|
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
|
-
const Log = require('../
|
|
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
|
-
|
|
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
|
-
|
|
46
|
+
Conf.setAll(this.config);
|
|
48
47
|
}
|
|
49
48
|
|
|
50
49
|
/**
|
|
51
50
|
* 启动通信模块
|
|
52
51
|
*/
|
|
53
52
|
async startSocket () {
|
|
54
|
-
|
|
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
|
-
|
|
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
|
-
//
|
|
105
|
-
|
|
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.
|
|
145
|
-
if (this.
|
|
146
|
-
this.
|
|
118
|
+
if (this.mainWindow) {
|
|
119
|
+
if (this.mainWindow.isMinimized()) {
|
|
120
|
+
this.mainWindow.restore();
|
|
147
121
|
}
|
|
148
|
-
this.
|
|
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 (
|
|
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 (
|
|
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.
|
|
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.
|
|
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;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const Log = require('../log');
|
|
2
|
+
const Ps = require('../ps');
|
|
3
|
+
const Channel = require('../const/channel');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 捕获异常
|
|
7
|
+
*/
|
|
8
|
+
exports.start = function() {
|
|
9
|
+
this.uncaughtExceptionHandler();
|
|
10
|
+
this.unhandledRejectionHandler();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 当进程上抛出异常而没有被捕获时触发该事件,并且使异常静默。
|
|
15
|
+
*/
|
|
16
|
+
exports.uncaughtExceptionHandler = function() {
|
|
17
|
+
process.on('uncaughtException', function(err) {
|
|
18
|
+
if (!(err instanceof Error)) {
|
|
19
|
+
err = new Error(String(err));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (err.name === 'Error') {
|
|
23
|
+
err.name = 'unhandledExceptionError';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
Log.coreLogger.error(err);
|
|
27
|
+
|
|
28
|
+
devError(err);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 当进程上抛出异常而没有被捕获时触发该事件。
|
|
34
|
+
*/
|
|
35
|
+
exports.uncaughtExceptionMonitorHandler = function() {
|
|
36
|
+
// process.on('uncaughtExceptionMonitor', function(err, origin) {
|
|
37
|
+
// if (!(err instanceof Error)) {
|
|
38
|
+
// err = new Error(String(err));
|
|
39
|
+
// }
|
|
40
|
+
|
|
41
|
+
// Log.coreLogger.error('uncaughtExceptionMonitor:',err);
|
|
42
|
+
// });
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 当promise中reject的异常在同步任务中没有使用catch捕获就会触发该事件,
|
|
47
|
+
* 即便是在异步情况下使用了catch也会触发该事件
|
|
48
|
+
*/
|
|
49
|
+
exports.unhandledRejectionHandler = function() {
|
|
50
|
+
process.on('unhandledRejection', function(err) {
|
|
51
|
+
if (!(err instanceof Error)) {
|
|
52
|
+
const newError = new Error(String(err));
|
|
53
|
+
// err maybe an object, try to copy the name, message and stack to the new error instance
|
|
54
|
+
if (err) {
|
|
55
|
+
if (err.name) newError.name = err.name;
|
|
56
|
+
if (err.message) newError.message = err.message;
|
|
57
|
+
if (err.stack) newError.stack = err.stack;
|
|
58
|
+
}
|
|
59
|
+
err = newError;
|
|
60
|
+
}
|
|
61
|
+
if (err.name === 'Error') {
|
|
62
|
+
err.name = 'unhandledRejectionError';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
Log.coreLogger.error(err);
|
|
66
|
+
|
|
67
|
+
devError(err);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 如果是子进程,发送错误到主进程控制台
|
|
73
|
+
*/
|
|
74
|
+
function devError (err) {
|
|
75
|
+
if (Ps.isForkedChild() && Ps.isDev()) {
|
|
76
|
+
let msgChannel = Channel.process.showException;
|
|
77
|
+
let errTips = (err && typeof err == 'object') ? err.toString() : '';
|
|
78
|
+
errTips += ' Error !!! Please See file ee-core.log or ee-error-xxx.log for details !'
|
|
79
|
+
let message = {
|
|
80
|
+
channel: msgChannel,
|
|
81
|
+
data: errTips
|
|
82
|
+
}
|
|
83
|
+
process.send(message);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -152,12 +152,12 @@ function normalizeConfig(httpConfig) {
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
if (config.httpAgent.timeout < 30000) {
|
|
155
|
-
Log.coreLogger.warn('[ee-core] [
|
|
155
|
+
Log.coreLogger.warn('[ee-core] [httpclient] config.httpclient.httpAgent.timeout(%s) can\'t below 30000, auto reset to 30000',
|
|
156
156
|
config.httpAgent.timeout);
|
|
157
157
|
config.httpAgent.timeout = 30000;
|
|
158
158
|
}
|
|
159
159
|
if (config.httpsAgent.timeout < 30000) {
|
|
160
|
-
Log.coreLogger.warn('[ee-core] [
|
|
160
|
+
Log.coreLogger.warn('[ee-core] [httpclient] config.httpclient.httpsAgent.timeout(%s) can\'t below 30000, auto reset to 30000',
|
|
161
161
|
config.httpsAgent.timeout);
|
|
162
162
|
config.httpsAgent.timeout = 30000;
|
|
163
163
|
}
|
package/index.js
CHANGED
|
@@ -1,47 +1,45 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* @namespace EeCore
|
|
5
3
|
*/
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
|
-
* @member {
|
|
6
|
+
* @member {app} EeCore#app
|
|
9
7
|
* @since 1.0.0
|
|
10
8
|
*/
|
|
11
|
-
const
|
|
9
|
+
const EE = require('./ee');
|
|
12
10
|
|
|
13
11
|
/**
|
|
14
12
|
* @member {Controller} EeCore#Controller
|
|
15
13
|
* @since 1.0.0
|
|
16
14
|
*/
|
|
17
|
-
const Controller = require('./
|
|
15
|
+
const Controller = require('./controller');
|
|
18
16
|
|
|
19
17
|
/**
|
|
20
18
|
* @member {Service} EeCore#Service
|
|
21
19
|
* @since 1.0.0
|
|
22
20
|
*/
|
|
23
|
-
const Service = require('./
|
|
21
|
+
const Service = require('./service');
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
24
|
* @member {Storage}
|
|
27
25
|
* @since 1.0.0
|
|
28
26
|
*/
|
|
29
|
-
const Storage = require('./
|
|
27
|
+
const Storage = require('./storage');
|
|
30
28
|
|
|
31
29
|
/**
|
|
32
30
|
* @member {Utils}
|
|
33
31
|
* @since 1.0.0
|
|
34
32
|
*/
|
|
35
|
-
const Utils = require('./
|
|
33
|
+
const Utils = require('./oldUtils');
|
|
36
34
|
|
|
37
35
|
/**
|
|
38
36
|
* @member {Socket}
|
|
39
37
|
* @since 1.0.0
|
|
40
38
|
*/
|
|
41
|
-
const Socket = require('./
|
|
39
|
+
const Socket = require('./socket');
|
|
42
40
|
|
|
43
41
|
module.exports = {
|
|
44
|
-
Appliaction,
|
|
42
|
+
Appliaction: EE.Appliaction,
|
|
45
43
|
Controller,
|
|
46
44
|
Service,
|
|
47
45
|
Storage,
|