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.
- package/app/application.js +31 -0
- package/app/boot.js +81 -0
- package/app/dir.js +27 -0
- package/app/events.js +56 -0
- package/app/index.js +7 -0
- package/config/config_loader.js +66 -0
- package/config/default_config.js +110 -0
- package/config/index.js +21 -83
- package/const/channel.js +26 -16
- package/const/index.js +0 -4
- package/controller/controller_loader.js +78 -0
- package/controller/index.js +18 -19
- package/core/index.js +6 -5
- package/core/{lib/loader → loader}/file_loader.js +39 -156
- package/core/utils/index.js +83 -0
- package/core/{lib/utils → utils}/timing.js +3 -2
- package/cross/cross.js +152 -0
- package/cross/index.js +6 -181
- package/cross/spawnProcess.js +34 -51
- package/electron/app/index.js +38 -54
- package/electron/index.js +13 -17
- package/electron/window/index.js +260 -65
- package/exception/index.js +34 -32
- package/html/index.js +7 -10
- package/index.js +4 -52
- package/jobs/child/app.js +9 -9
- package/jobs/child/forkProcess.js +29 -45
- package/jobs/child/index.js +13 -10
- package/jobs/child-pool/index.js +13 -11
- package/jobs/index.js +2 -4
- package/loader/index.js +91 -144
- package/log/index.js +74 -57
- package/log/logger.js +76 -84
- package/message/childMessage.js +12 -13
- package/message/index.js +7 -16
- package/package.json +2 -2
- package/ps/index.js +137 -223
- package/socket/httpServer.js +46 -43
- package/socket/index.js +52 -69
- package/socket/ipcServer.js +80 -94
- package/socket/socketServer.js +31 -24
- package/storage/index.js +5 -37
- package/storage/sqliteStorage.js +18 -18
- package/utils/extend.js +10 -5
- package/utils/helper.js +38 -42
- package/utils/index.js +40 -23
- package/utils/ip.js +5 -45
- package/utils/is.js +107 -141
- package/utils/json.js +15 -7
- package/utils/pargv.js +5 -1
- package/utils/{get-port → port}/index.js +4 -26
- package/utils/wrap.js +8 -3
- package/addon/index.js +0 -35
- package/addon/window/index.js +0 -99
- package/bin/tools.js +0 -8
- package/config/cache.js +0 -42
- package/config/config.default.js +0 -331
- package/controller/baseContextClass.js +0 -25
- package/core/lib/ee.js +0 -216
- package/core/lib/loader/context_loader.js +0 -106
- package/core/lib/loader/ee_loader.js +0 -435
- package/core/lib/loader/mixin/addon.js +0 -32
- package/core/lib/loader/mixin/config.js +0 -130
- package/core/lib/loader/mixin/controller.js +0 -125
- package/core/lib/loader/mixin/service.js +0 -28
- package/core/lib/utils/base_context_class.js +0 -34
- package/core/lib/utils/function.js +0 -30
- package/core/lib/utils/index.js +0 -133
- package/core/lib/utils/sequencify.js +0 -59
- package/ee/appLoader.js +0 -48
- package/ee/application.js +0 -100
- package/ee/baseApp.js +0 -104
- package/ee/eeApp.js +0 -409
- package/ee/index.js +0 -58
- package/electron/window/winState.js +0 -186
- package/httpclient/index.js +0 -161
- package/jobs/baseJobClass.js +0 -16
- package/jobs/renderer/index.js +0 -141
- package/jobs/renderer/loadView.js +0 -41
- package/jobs/unification.js +0 -64
- package/main/index.js +0 -57
- package/old-utils/index.js +0 -91
- package/services/baseContextClass.js +0 -24
- package/services/index.js +0 -41
- package/socket/io.js +0 -28
- package/storage/jsondb/adapters/Base.js +0 -23
- package/storage/jsondb/adapters/FileSync.js +0 -64
- package/storage/jsondb/main.js +0 -55
- package/storage/jsondbStorage.js +0 -196
- package/utils/co.js +0 -237
- package/utils/copyto.js +0 -161
- package/utils/depd/index.js +0 -538
- package/utils/depd/lib/browser/index.js +0 -77
- package/utils/get-port/index.d.ts +0 -64
- package/utils/time/index.js +0 -20
- package/utils/time/ms.js +0 -162
package/cross/index.js
CHANGED
|
@@ -1,183 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
const EventEmitter = require('events');
|
|
3
|
-
const Conf = require('../config/cache');
|
|
4
|
-
const Helper = require('../utils/helper');
|
|
5
|
-
const Ps = require('../ps');
|
|
6
|
-
const SpawnProcess = require('./spawnProcess');
|
|
7
|
-
const Channel = require('../const/channel');
|
|
8
|
-
const extend = require('../utils/extend');
|
|
9
|
-
const GetPort = require('../utils/get-port');
|
|
1
|
+
'use strict';
|
|
10
2
|
|
|
11
|
-
|
|
12
|
-
* Cross-language service
|
|
13
|
-
* 跨语言服务
|
|
14
|
-
*/
|
|
15
|
-
const CrossLanguageService = {
|
|
3
|
+
const { CrossProcess, cross} = require('./cross');
|
|
16
4
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* {pid:{name,entity}, pid:{name,entity}, ...}
|
|
22
|
-
*/
|
|
23
|
-
children: {},
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* name唯一
|
|
27
|
-
* {name:pid, name:pid, ...}
|
|
28
|
-
*/
|
|
29
|
-
childrenMap: {},
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* create
|
|
33
|
-
*/
|
|
34
|
-
async create() {
|
|
35
|
-
|
|
36
|
-
// boot services
|
|
37
|
-
const servicesCfg = Conf.getValue('cross');
|
|
38
|
-
//await Helper.sleep(5 * 1000);
|
|
39
|
-
|
|
40
|
-
for (let key of Object.keys(servicesCfg)) {
|
|
41
|
-
let cfg = servicesCfg[key];
|
|
42
|
-
if (cfg.enable == true) {
|
|
43
|
-
this.run(key)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* _initEventEmitter
|
|
50
|
-
*/
|
|
51
|
-
_initEventEmitter() {
|
|
52
|
-
if (this.emitter) {
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
this.emitter = new EventEmitter();
|
|
56
|
-
this.emitter.on(Channel.events.childProcessExit, (data) => {
|
|
57
|
-
const child = this.children[data.pid];
|
|
58
|
-
delete this.childrenMap[child.name];
|
|
59
|
-
delete this.children[data.pid];
|
|
60
|
-
});
|
|
61
|
-
this.emitter.on(Channel.events.childProcessError, (data) => {
|
|
62
|
-
const child = this.children[data.pid];
|
|
63
|
-
delete this.childrenMap[child.name];
|
|
64
|
-
delete this.children[data.pid];
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* run
|
|
70
|
-
*/
|
|
71
|
-
async run(service, opt = {}) {
|
|
72
|
-
// init dir
|
|
73
|
-
this._initPath();
|
|
74
|
-
|
|
75
|
-
const allConfig = Conf.all();
|
|
76
|
-
const defaultOpt = allConfig.cross[service] || {};
|
|
77
|
-
const targetConf = extend(true, {}, defaultOpt, opt);
|
|
78
|
-
if (Object.keys(targetConf).length == 0) {
|
|
79
|
-
throw new Error(`[ee-core] [cross] The service [${service}] config does not exit`);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// eventEmitter
|
|
83
|
-
this._initEventEmitter();
|
|
84
|
-
|
|
85
|
-
// format params
|
|
86
|
-
let tmpArgs = targetConf.args;
|
|
87
|
-
let confPort = parseInt(Helper.getValueFromArgv(tmpArgs, 'port'));
|
|
88
|
-
// 某些程序给它传入不存在的参数时会报错
|
|
89
|
-
if (isNaN(confPort) && targetConf.port > 0) {
|
|
90
|
-
confPort = targetConf.port;
|
|
91
|
-
}
|
|
92
|
-
if (confPort > 0) {
|
|
93
|
-
// 动态生成port,传入的端口必须为int
|
|
94
|
-
confPort = await GetPort({ port: confPort });
|
|
95
|
-
// 替换port
|
|
96
|
-
targetConf.args = Helper.replaceArgsValue(tmpArgs, "port", String(confPort));
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 创建进程
|
|
100
|
-
const subProcess = new SpawnProcess(this, { targetConf, port: confPort });
|
|
101
|
-
let uniqueName = targetConf.name;
|
|
102
|
-
if (this.childrenMap.hasOwnProperty(uniqueName)) {
|
|
103
|
-
uniqueName = uniqueName + "-" + String(subProcess.pid);
|
|
104
|
-
}
|
|
105
|
-
this.childrenMap[uniqueName] = subProcess.pid;
|
|
106
|
-
subProcess.name = uniqueName;
|
|
107
|
-
this.children[subProcess.pid] = {
|
|
108
|
-
name: uniqueName,
|
|
109
|
-
entity: subProcess
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
return subProcess;
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
killAll() {
|
|
116
|
-
Object.keys(this.children).forEach(pid => {
|
|
117
|
-
this.kill(pid)
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
kill(pid) {
|
|
122
|
-
const entity = this.getProc(pid);
|
|
123
|
-
if (entity) {
|
|
124
|
-
entity.kill();
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
killByName(name) {
|
|
129
|
-
const entity = this.getProcByName(name);
|
|
130
|
-
if (entity) {
|
|
131
|
-
entity.kill();
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
getUrl(name) {
|
|
136
|
-
const entity = this.getProcByName(name);
|
|
137
|
-
const url = entity.getUrl();
|
|
138
|
-
|
|
139
|
-
return url;
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
// 获取 proc
|
|
143
|
-
getProcByName(name) {
|
|
144
|
-
const pid = this.childrenMap[name];
|
|
145
|
-
if (!pid) {
|
|
146
|
-
throw new Error(`[ee-core] [cross] The process named [${name}] does not exit`);
|
|
147
|
-
}
|
|
148
|
-
const entity = this.getProc(pid);
|
|
149
|
-
|
|
150
|
-
return entity;
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
// 获取 proc
|
|
154
|
-
getProc(pid) {
|
|
155
|
-
const child = this.children[pid];
|
|
156
|
-
if (!pid) {
|
|
157
|
-
throw new Error(`[ee-core] [cross] The process pid [${pid}] does not exit`);
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return child.entity;
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* 获取pids
|
|
165
|
-
*/
|
|
166
|
-
getPids() {
|
|
167
|
-
let pids = Object.keys(this.children);
|
|
168
|
-
return pids;
|
|
169
|
-
},
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* init path
|
|
173
|
-
*/
|
|
174
|
-
_initPath() {
|
|
175
|
-
const pathname = Ps.getUserHomeConfigDir();
|
|
176
|
-
if (!fs.existsSync(pathname)) {
|
|
177
|
-
Helper.mkdir(pathname, {mode: 0o755});
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
module.exports = CrossLanguageService;
|
|
5
|
+
module.exports = {
|
|
6
|
+
CrossProcess,
|
|
7
|
+
cross
|
|
8
|
+
};
|
package/cross/spawnProcess.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
1
3
|
const EventEmitter = require('events');
|
|
2
4
|
const path = require('path');
|
|
3
5
|
const crossSpawn = require('cross-spawn');
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
6
|
+
const { coreLogger } = require('../log');
|
|
7
|
+
const { getExtraResourcesDir, isPackaged, isDev, getBaseDir } = require('../ps');
|
|
8
|
+
const { Events } = require('../const/channel');
|
|
9
|
+
const { getRandomString, getValueFromArgv } = require('../utils/helper');
|
|
10
|
+
const { is } = require('../utils');
|
|
11
|
+
const { parseArgv } = require('../utils/pargv');
|
|
12
|
+
const { app: electronApp } = require('electron');
|
|
11
13
|
|
|
12
14
|
class SpawnProcess {
|
|
13
15
|
constructor(host, opt = {}) {
|
|
@@ -35,9 +37,9 @@ class SpawnProcess {
|
|
|
35
37
|
// Launch executable program
|
|
36
38
|
let cmdPath = '';
|
|
37
39
|
let cmdArgs = targetConf.args;
|
|
38
|
-
let execDir =
|
|
40
|
+
let execDir = getExtraResourcesDir();
|
|
39
41
|
let standardOutput = ['inherit', 'inherit', 'inherit', 'ipc'];
|
|
40
|
-
if (
|
|
42
|
+
if (isPackaged()) {
|
|
41
43
|
standardOutput = ['ignore', 'ignore', 'ignore', 'ipc'];
|
|
42
44
|
}
|
|
43
45
|
if (targetConf.stdio) {
|
|
@@ -51,18 +53,18 @@ class SpawnProcess {
|
|
|
51
53
|
throw new Error(`[ee-core] [cross] The config [directory] attribute does not exist`);
|
|
52
54
|
}
|
|
53
55
|
cmdPath = cmd;
|
|
54
|
-
if (!path.isAbsolute(cmd) && !
|
|
55
|
-
cmdPath = path.join(
|
|
56
|
+
if (!path.isAbsolute(cmd) && !isDev()) {
|
|
57
|
+
cmdPath = path.join(getExtraResourcesDir(), cmd);
|
|
56
58
|
}
|
|
57
59
|
} else {
|
|
58
|
-
cmdPath = path.join(
|
|
60
|
+
cmdPath = path.join(getExtraResourcesDir(), targetConf.name);
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
// windows
|
|
62
|
-
if (
|
|
64
|
+
if (is.windows() && path.extname(cmdPath) != '.exe') {
|
|
63
65
|
// Complete the executable program extension
|
|
64
66
|
// notice: python.exe may bring up the App Store
|
|
65
|
-
if (targetConf.windowsExtname === true || !
|
|
67
|
+
if (targetConf.windowsExtname === true || !isDev()) {
|
|
66
68
|
cmdPath += ".exe";
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -71,16 +73,16 @@ class SpawnProcess {
|
|
|
71
73
|
if (directory && path.isAbsolute(directory)) {
|
|
72
74
|
execDir = directory;
|
|
73
75
|
} else if (directory && !path.isAbsolute(directory)) {
|
|
74
|
-
if (
|
|
75
|
-
execDir = path.join(
|
|
76
|
+
if (isDev()) {
|
|
77
|
+
execDir = path.join(getBaseDir(), directory);
|
|
76
78
|
} else {
|
|
77
|
-
execDir = path.join(
|
|
79
|
+
execDir = path.join(getExtraResourcesDir(), directory);
|
|
78
80
|
}
|
|
79
81
|
} else {
|
|
80
|
-
execDir =
|
|
82
|
+
execDir = getExtraResourcesDir();
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
|
|
85
|
+
coreLogger.info(`[ee-core] [cross/run] cmd: ${cmdPath}, args: ${cmdArgs}`);
|
|
84
86
|
const coreProcess = crossSpawn(cmdPath, cmdArgs, {
|
|
85
87
|
stdio: standardOutput,
|
|
86
88
|
detached: false,
|
|
@@ -94,9 +96,9 @@ class SpawnProcess {
|
|
|
94
96
|
let data = {
|
|
95
97
|
pid: this.pid
|
|
96
98
|
}
|
|
97
|
-
this.host.emitter.emit(
|
|
99
|
+
this.host.emitter.emit(Events.childProcessExit, data);
|
|
98
100
|
// Child process closed: The child process was killed externally or an internal error caused the application to stop, resulting in the application exiting
|
|
99
|
-
|
|
101
|
+
coreLogger.info(`[ee-core] [corss/process] received a exit from child-process, code:${code}, signal:${signal}, pid:${this.pid}, cmd:${cmdPath}, args: ${cmdArgs}`);
|
|
100
102
|
this._exitElectron();
|
|
101
103
|
});
|
|
102
104
|
|
|
@@ -104,8 +106,8 @@ class SpawnProcess {
|
|
|
104
106
|
let data = {
|
|
105
107
|
pid: this.pid
|
|
106
108
|
}
|
|
107
|
-
this.host.emitter.emit(
|
|
108
|
-
|
|
109
|
+
this.host.emitter.emit(Events.childProcessError, data);
|
|
110
|
+
coreLogger.error(`[ee-core] [corss/process] received a error from child-process, error: ${err}, pid:${this.pid}`);
|
|
109
111
|
this._exitElectron();
|
|
110
112
|
});
|
|
111
113
|
}
|
|
@@ -121,29 +123,9 @@ class SpawnProcess {
|
|
|
121
123
|
}, timeout)
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
// send(message) {
|
|
125
|
-
// return this.sendByType(message, 'message');
|
|
126
|
-
// }
|
|
127
|
-
|
|
128
|
-
// close() {
|
|
129
|
-
// return this.sendByType('close', 'close');
|
|
130
|
-
// }
|
|
131
|
-
|
|
132
|
-
// async sendByType(message, type) {
|
|
133
|
-
// const msg = typeof message === 'string' ? message : JSON.stringify(message);
|
|
134
|
-
// const id = this._generateId();
|
|
135
|
-
|
|
136
|
-
// this.child.send({
|
|
137
|
-
// id,
|
|
138
|
-
// type,
|
|
139
|
-
// data: msg,
|
|
140
|
-
// });
|
|
141
|
-
// return;
|
|
142
|
-
// }
|
|
143
|
-
|
|
144
126
|
getUrl() {
|
|
145
|
-
const ssl =
|
|
146
|
-
let hostname =
|
|
127
|
+
const ssl = getValueFromArgv(this.config.args, 'ssl');
|
|
128
|
+
let hostname = getValueFromArgv(this.config.args, 'hostname')
|
|
147
129
|
let protocol = 'http://';
|
|
148
130
|
if (ssl && (ssl == 'true' || ssl == '1')) {
|
|
149
131
|
protocol = 'https://';
|
|
@@ -155,7 +137,7 @@ class SpawnProcess {
|
|
|
155
137
|
}
|
|
156
138
|
|
|
157
139
|
getArgsObj() {
|
|
158
|
-
const obj =
|
|
140
|
+
const obj = parseArgv(this.config.args);
|
|
159
141
|
return obj;
|
|
160
142
|
}
|
|
161
143
|
|
|
@@ -164,7 +146,7 @@ class SpawnProcess {
|
|
|
164
146
|
}
|
|
165
147
|
|
|
166
148
|
_generateId() {
|
|
167
|
-
const rid =
|
|
149
|
+
const rid = getRandomString();
|
|
168
150
|
return `node:${this.pid}:${rid}`;
|
|
169
151
|
}
|
|
170
152
|
|
|
@@ -172,14 +154,15 @@ class SpawnProcess {
|
|
|
172
154
|
* exit electron
|
|
173
155
|
*/
|
|
174
156
|
_exitElectron(timeout = 1000) {
|
|
175
|
-
const { CoreApp } = EE;
|
|
176
157
|
if (this.config.appExit) {
|
|
177
158
|
setTimeout(() => {
|
|
178
|
-
//
|
|
179
|
-
|
|
159
|
+
// 主进程退出
|
|
160
|
+
electronApp.quit();
|
|
180
161
|
}, timeout)
|
|
181
162
|
}
|
|
182
163
|
}
|
|
183
164
|
}
|
|
184
165
|
|
|
185
|
-
module.exports =
|
|
166
|
+
module.exports = {
|
|
167
|
+
SpawnProcess
|
|
168
|
+
};
|
package/electron/app/index.js
CHANGED
|
@@ -1,64 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const debug = require('debug')('ee-core:electron:app');
|
|
4
|
+
const { app: electronApp } = require('electron');
|
|
5
|
+
const { coreLogger } = require('../../log');
|
|
6
|
+
const { is } = require('../../utils');
|
|
7
|
+
const { cross } = require('../../cross');
|
|
8
|
+
const { createMainWindow, setCloseAndQuit, loadServer } = require('../window');
|
|
9
|
+
const { eventBus, ElectronAppReady, BeforeClose, Preload } = require('../../app/events');
|
|
10
|
+
const { getConfig } = require('../../config');
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
13
|
+
* 创建electron应用
|
|
11
14
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const gotTheLock = app.requestSingleInstanceLock();
|
|
21
|
-
if (!gotTheLock) {
|
|
22
|
-
app.quit();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
app.whenReady().then(() => {
|
|
26
|
-
CoreApp.createWindow();
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
// 显示首次打开的窗口
|
|
30
|
-
app.on('second-instance', () => {
|
|
31
|
-
Log.coreLogger.info('[ee-core] [lib/eeApp] second-instance');
|
|
32
|
-
Window.restoreMainWindow();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
app.on('window-all-closed', () => {
|
|
36
|
-
if (!UtilsIs.macOS()) {
|
|
37
|
-
Log.coreLogger.info('[ee-core] [lib/eeApp] window-all-closed quit');
|
|
38
|
-
CoreApp.appQuit();
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
app.on('before-quit', () => {
|
|
43
|
-
Electron.extra.closeWindow = true;
|
|
15
|
+
function createElectron() {
|
|
16
|
+
const { singleLock } = getConfig();
|
|
17
|
+
// 允许多个实例
|
|
18
|
+
const gotTheLock = electronApp.requestSingleInstanceLock();
|
|
19
|
+
if (singleLock && !gotTheLock) {
|
|
20
|
+
electronApp.quit();
|
|
21
|
+
}
|
|
44
22
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
electronApp.whenReady().then(() => {
|
|
24
|
+
createMainWindow();
|
|
25
|
+
eventBus.emitLifecycle(Preload);
|
|
26
|
+
loadServer();
|
|
27
|
+
})
|
|
48
28
|
|
|
49
|
-
|
|
50
|
-
|
|
29
|
+
electronApp.on('window-all-closed', () => {
|
|
30
|
+
if (!is.macOS()) {
|
|
31
|
+
coreLogger.info('[ee-core] [lib/eeApp] window-all-closed quit');
|
|
32
|
+
electronApp.quit();
|
|
51
33
|
}
|
|
34
|
+
})
|
|
52
35
|
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
electronApp.on('before-quit', () => {
|
|
37
|
+
setCloseAndQuit(true);
|
|
38
|
+
eventBus.emitLifecycle(BeforeClose);
|
|
39
|
+
cross.killAll();
|
|
40
|
+
})
|
|
55
41
|
|
|
56
|
-
|
|
57
|
-
* 退出app
|
|
58
|
-
*/
|
|
59
|
-
quit() {
|
|
60
|
-
app.quit();
|
|
61
|
-
}
|
|
42
|
+
eventBus.emitLifecycle(ElectronAppReady);
|
|
62
43
|
}
|
|
63
44
|
|
|
64
|
-
module.exports =
|
|
45
|
+
module.exports = {
|
|
46
|
+
electronApp,
|
|
47
|
+
createElectron,
|
|
48
|
+
};
|
package/electron/index.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const { createElectron } = require("./app");
|
|
4
|
+
const { getMainWindow, setCloseAndQuit, getCloseAndQuit } = require("./window");
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return Window.getMainWindow();
|
|
10
|
-
},
|
|
6
|
+
// load socket server
|
|
7
|
+
function loadElectron() {
|
|
8
|
+
createElectron();
|
|
9
|
+
}
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
module.exports = Electron;
|
|
11
|
+
module.exports = {
|
|
12
|
+
loadElectron,
|
|
13
|
+
getMainWindow,
|
|
14
|
+
setCloseAndQuit,
|
|
15
|
+
getCloseAndQuit
|
|
16
|
+
};
|