ee-core 2.2.0-beta.2 → 2.2.0-beta.4
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 -2
- package/core/lib/loader/ee_loader.js +1 -1
- package/core/lib/loader/mixin/controller.js +1 -1
- package/ee/application.js +2 -0
- package/ee/eeApp.js +18 -4
- package/main/index.js +7 -0
- package/package.json +1 -1
- package/ps/index.js +14 -0
package/core/lib/ee.js
CHANGED
|
@@ -21,8 +21,8 @@ class EeCore extends KoaApplication {
|
|
|
21
21
|
options.type = options.type || 'application';
|
|
22
22
|
|
|
23
23
|
assert(typeof options.baseDir === 'string', 'options.baseDir required, and must be a string');
|
|
24
|
-
assert(fs.existsSync(options.baseDir), `Directory ${options.baseDir} not exists`);
|
|
25
|
-
assert(fs.statSync(options.baseDir).isDirectory(), `Directory ${options.baseDir} is not a directory`);
|
|
24
|
+
// assert(fs.existsSync(options.baseDir), `Directory ${options.baseDir} not exists`);
|
|
25
|
+
// assert(fs.statSync(options.baseDir).isDirectory(), `Directory ${options.baseDir} is not a directory`);
|
|
26
26
|
|
|
27
27
|
super();
|
|
28
28
|
|
|
@@ -25,7 +25,7 @@ class EeLoader {
|
|
|
25
25
|
*/
|
|
26
26
|
constructor(options) {
|
|
27
27
|
this.options = options;
|
|
28
|
-
assert(fs.existsSync(this.options.baseDir), `${this.options.baseDir} not exists`);
|
|
28
|
+
// assert(fs.existsSync(this.options.baseDir), `${this.options.baseDir} not exists`);
|
|
29
29
|
assert(this.options.app, 'options.app is required');
|
|
30
30
|
assert(this.options.logger, 'options.logger is required');
|
|
31
31
|
|
|
@@ -47,7 +47,7 @@ module.exports = {
|
|
|
47
47
|
const controllerBase = opt.directory;
|
|
48
48
|
|
|
49
49
|
this.loadToApp(controllerBase, 'controller', opt);
|
|
50
|
-
this.options.logger.info('[ee-core] [core/.../controller] loaded: %s', controllerBase);
|
|
50
|
+
//this.options.logger.info('[ee-core] [core/.../controller] loaded: %s', controllerBase);
|
|
51
51
|
this.timing.end('Load Controller');
|
|
52
52
|
},
|
|
53
53
|
|
package/ee/application.js
CHANGED
package/ee/eeApp.js
CHANGED
|
@@ -28,9 +28,11 @@ class EeApp extends BaseApp {
|
|
|
28
28
|
* 生成端口
|
|
29
29
|
*/
|
|
30
30
|
async createPorts() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
if (Ps.isFrameworkMode()) {
|
|
32
|
+
const mainPort = await GetPort({port: this.config.mainServer.port});
|
|
33
|
+
process.env.EE_MAIN_PORT = mainPort;
|
|
34
|
+
this.config.mainServer.port = mainPort;
|
|
35
|
+
}
|
|
34
36
|
|
|
35
37
|
if (this.config.socketServer.enable) {
|
|
36
38
|
const socketPort = await GetPort({port: this.config.socketServer.port});
|
|
@@ -59,6 +61,7 @@ class EeApp extends BaseApp {
|
|
|
59
61
|
* 创建electron应用
|
|
60
62
|
*/
|
|
61
63
|
async createElectronApp() {
|
|
64
|
+
if (!Ps.isFrameworkMode()) return;
|
|
62
65
|
const newApp = CoreElectronApp.create();
|
|
63
66
|
if (!newApp) {
|
|
64
67
|
return
|
|
@@ -197,7 +200,7 @@ class EeApp extends BaseApp {
|
|
|
197
200
|
|
|
198
201
|
// 注册主窗口Contents id
|
|
199
202
|
const addonsCfg = this.config.addons;
|
|
200
|
-
if (addonsCfg.window.enable) {
|
|
203
|
+
if (addonsCfg.window.enable && Ps.isFrameworkMode()) {
|
|
201
204
|
const win = this.mainWindow;
|
|
202
205
|
const addonWindow = this.addon.window;
|
|
203
206
|
addonWindow.registerWCid('main', win.webContents.id);
|
|
@@ -218,6 +221,17 @@ class EeApp extends BaseApp {
|
|
|
218
221
|
}
|
|
219
222
|
}
|
|
220
223
|
|
|
224
|
+
/**
|
|
225
|
+
* module模式初始化
|
|
226
|
+
*/
|
|
227
|
+
async InitModuleMode() {
|
|
228
|
+
if (!Ps.isModuleMode()) return;
|
|
229
|
+
|
|
230
|
+
await this._loderAddons();
|
|
231
|
+
|
|
232
|
+
await this._loderPreload();
|
|
233
|
+
}
|
|
234
|
+
|
|
221
235
|
/**
|
|
222
236
|
* electron app已经准备好,主窗口还未创建
|
|
223
237
|
*/
|
package/main/index.js
CHANGED
|
@@ -23,6 +23,13 @@ class ElectronEgg {
|
|
|
23
23
|
}
|
|
24
24
|
process.env.EE_MODE = this.mode;
|
|
25
25
|
|
|
26
|
+
// module mode
|
|
27
|
+
if (Ps.isModuleMode()) {
|
|
28
|
+
const { Application } = EE;
|
|
29
|
+
new Application();
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
26
33
|
let baseDir = path.join(app.getAppPath(), 'electron');
|
|
27
34
|
if (Utils.isEncrypt(app.getAppPath())) {
|
|
28
35
|
baseDir = Ps.getEncryptDir(app.getAppPath());
|
package/package.json
CHANGED
package/ps/index.js
CHANGED
|
@@ -18,6 +18,20 @@ exports.verifyMode = function(mode) {
|
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* 是否为框架模式
|
|
23
|
+
*/
|
|
24
|
+
exports.isFrameworkMode = function() {
|
|
25
|
+
return (process.env.EE_MODE === 'framework');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 是否为模块模式
|
|
30
|
+
*/
|
|
31
|
+
exports.isModuleMode = function() {
|
|
32
|
+
return (process.env.EE_MODE === 'module');
|
|
33
|
+
}
|
|
34
|
+
|
|
21
35
|
/**
|
|
22
36
|
* 当前进程的所有env
|
|
23
37
|
*/
|