ee-core 2.12.0 → 4.0.0
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.d.ts +5 -0
- package/app/application.js +31 -0
- package/app/boot.d.ts +5 -0
- package/app/boot.js +74 -0
- package/app/dir.d.ts +1 -0
- package/app/dir.js +27 -0
- package/app/events.d.ts +14 -0
- package/app/events.js +56 -0
- package/app/index.d.ts +2 -0
- package/app/index.js +7 -0
- package/config/config_loader.d.ts +13 -0
- package/config/config_loader.js +19 -23
- package/config/default_config.d.ts +95 -0
- package/config/default_config.js +111 -0
- package/config/index.d.ts +28 -0
- package/config/index.js +20 -37
- package/const/channel.d.ts +16 -0
- package/const/channel.js +26 -16
- package/controller/controller_loader.d.ts +9 -0
- package/controller/controller_loader.js +78 -0
- package/controller/index.d.ts +2 -0
- package/controller/index.js +18 -19
- package/core/index.d.ts +2 -0
- package/core/index.js +6 -5
- package/core/loader/file_loader.d.ts +66 -0
- package/core/{lib/loader → loader}/file_loader.js +39 -156
- package/core/utils/index.d.ts +12 -0
- package/core/utils/index.js +83 -0
- package/core/utils/timing.d.ts +22 -0
- package/core/{lib/utils → utils}/timing.js +3 -2
- package/cross/cross.d.ts +19 -0
- package/cross/cross.js +152 -0
- package/cross/crossProcess.d.ts +29 -0
- package/cross/{spawnProcess.js → crossProcess.js} +36 -53
- package/cross/index.d.ts +2 -0
- package/cross/index.js +6 -181
- package/electron/app/index.d.ts +5 -0
- package/electron/app/index.js +38 -54
- package/electron/index.d.ts +3 -0
- package/electron/index.js +13 -17
- package/electron/window/index.d.ts +6 -0
- package/electron/window/index.js +260 -65
- package/exception/index.d.ts +9 -0
- package/exception/index.js +42 -54
- package/html/index.d.ts +1 -0
- package/html/index.js +7 -10
- package/index.d.ts +2 -0
- package/index.js +4 -52
- package/jobs/child/app.d.ts +1 -0
- package/jobs/child/app.js +10 -10
- package/jobs/child/index.d.ts +13 -0
- package/jobs/child/index.js +14 -11
- package/jobs/child/jobProcess.d.ts +16 -0
- package/jobs/child/{forkProcess.js → jobProcess.js} +31 -62
- package/jobs/child-pool/index.d.ts +26 -0
- package/jobs/child-pool/index.js +25 -48
- package/jobs/index.d.ts +3 -0
- package/jobs/index.js +2 -4
- package/jobs/load-balancer/algorithm/index.d.ts +4 -0
- package/jobs/load-balancer/algorithm/minimumConnection.d.ts +2 -0
- package/jobs/load-balancer/algorithm/polling.d.ts +2 -0
- package/jobs/load-balancer/algorithm/random.d.ts +2 -0
- package/jobs/load-balancer/algorithm/specify.d.ts +2 -0
- package/jobs/load-balancer/algorithm/weights.d.ts +2 -0
- package/jobs/load-balancer/algorithm/weightsMinimumConnection.d.ts +2 -0
- package/jobs/load-balancer/algorithm/weightsPolling.d.ts +2 -0
- package/jobs/load-balancer/algorithm/weightsRandom.d.ts +2 -0
- package/jobs/load-balancer/consts.d.ts +8 -0
- package/jobs/load-balancer/index.d.ts +96 -0
- package/jobs/load-balancer/scheduler.d.ts +16 -0
- package/loader/index.d.ts +9 -0
- package/loader/index.js +73 -143
- package/log/index.d.ts +5 -0
- package/log/index.js +74 -57
- package/log/logger.d.ts +2 -0
- package/log/logger.js +75 -80
- package/message/childMessage.d.ts +10 -0
- package/message/childMessage.js +15 -25
- package/message/index.d.ts +3 -0
- package/message/index.js +7 -16
- package/package.json +8 -2
- package/ps/index.d.ts +37 -0
- package/ps/index.js +135 -238
- package/socket/httpServer.d.ts +8 -0
- package/socket/httpServer.js +55 -45
- package/socket/index.d.ts +10 -0
- package/socket/index.js +52 -69
- package/socket/ipcServer.d.ts +9 -0
- package/socket/ipcServer.js +87 -94
- package/socket/socketServer.d.ts +10 -0
- package/socket/socketServer.js +37 -25
- package/storage/index.d.ts +5 -0
- package/storage/index.js +5 -37
- package/storage/sqliteStorage.d.ts +16 -0
- package/storage/sqliteStorage.js +20 -20
- package/tsconfig.json +14 -0
- package/utils/extend.d.ts +2 -0
- package/utils/extend.js +10 -5
- package/utils/helper.d.ts +14 -0
- package/utils/helper.js +39 -53
- package/utils/index.d.ts +10 -0
- package/utils/index.js +47 -40
- package/utils/ip.d.ts +2 -0
- package/utils/ip.js +5 -45
- package/utils/is.d.ts +14 -0
- package/utils/is.js +107 -141
- package/utils/json.d.ts +5 -0
- package/utils/json.js +15 -7
- package/utils/pargv.d.ts +3 -0
- package/utils/pargv.js +5 -1
- package/utils/port/index.d.ts +1 -0
- package/utils/{get-port → port}/index.js +4 -26
- package/utils/wrap.d.ts +4 -0
- 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 -62
- package/config/config.default.js +0 -331
- package/const/index.js +0 -9
- 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 -101
- package/ee/baseApp.js +0 -99
- package/ee/eeApp.js +0 -406
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ee-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "ee core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"agentkeepalive": "^4.2.0",
|
|
16
|
+
"axios": "^1.7.9",
|
|
16
17
|
"bytenode": "^1.3.6",
|
|
17
18
|
"chalk": "^4.1.2",
|
|
18
19
|
"cross-spawn": "^7.0.3",
|
|
19
20
|
"dayjs": "^1.11.7",
|
|
20
21
|
"debug": "^4.3.3",
|
|
21
|
-
"egg-errors": "^2.3.0",
|
|
22
22
|
"egg-logger": "^2.7.1",
|
|
23
23
|
"globby": "^10.0.0",
|
|
24
24
|
"is-type-of": "^1.2.1",
|
|
@@ -34,5 +34,11 @@
|
|
|
34
34
|
"socket.io": "^4.6.1",
|
|
35
35
|
"socket.io-client": "^4.6.1",
|
|
36
36
|
"urllib": "^2.38.0"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/better-sqlite3": "^7.6.12",
|
|
40
|
+
"@types/electron": "^1.4.38",
|
|
41
|
+
"@types/node": "^20.16.0",
|
|
42
|
+
"typescript": "^5.7.2"
|
|
37
43
|
}
|
|
38
44
|
}
|
package/ps/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export declare function allEnv(): NodeJS.ProcessEnv;
|
|
2
|
+
export declare function env(): string;
|
|
3
|
+
export declare function isProd(): boolean;
|
|
4
|
+
export declare function isDev(): boolean;
|
|
5
|
+
export declare function isRenderer(): boolean;
|
|
6
|
+
export declare function isMain(): boolean;
|
|
7
|
+
export declare function isForkedChild(): boolean;
|
|
8
|
+
export declare function processType(): string;
|
|
9
|
+
export declare function appName(): string;
|
|
10
|
+
export declare function appVersion(): string;
|
|
11
|
+
export declare function getDataDir(): string;
|
|
12
|
+
export declare function getLogDir(): string;
|
|
13
|
+
export declare function getBundleDir(basePath: string): string;
|
|
14
|
+
export declare function getRootDir(): string;
|
|
15
|
+
export declare function getBaseDir(): string;
|
|
16
|
+
export declare function getElectronDir(): string;
|
|
17
|
+
export declare function getPublicDir(): string;
|
|
18
|
+
export declare function getExtraResourcesDir(): string;
|
|
19
|
+
export declare function getAppUserDataDir(): string;
|
|
20
|
+
export declare function getExecDir(): string;
|
|
21
|
+
export declare function getUserHomeDir(): string;
|
|
22
|
+
export declare function getUserHomeAppDir(): string;
|
|
23
|
+
export declare function getUserHomeHiddenAppDir(): string;
|
|
24
|
+
export declare function getSocketPort(): number;
|
|
25
|
+
export declare function getHttpPort(): number;
|
|
26
|
+
export declare function isPackaged(): boolean;
|
|
27
|
+
export declare function isHotReload(): boolean;
|
|
28
|
+
export declare function exit(code?: number): never;
|
|
29
|
+
export declare function makeMessage(msg?: {}): {
|
|
30
|
+
channel: string;
|
|
31
|
+
event: string;
|
|
32
|
+
data: {};
|
|
33
|
+
};
|
|
34
|
+
export declare function exitChildJob(code?: number): void;
|
|
35
|
+
export declare function isChildJob(): boolean;
|
|
36
|
+
export declare function isChildPoolJob(): boolean;
|
|
37
|
+
export declare function getArgumentByName(name: string): string;
|
package/ps/index.js
CHANGED
|
@@ -1,223 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
const eis = require('../utils/is');
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 初始化模式
|
|
6
|
-
*/
|
|
7
|
-
exports.initMode = function(mode) {
|
|
8
|
-
if(process.env.EE_MODE !== undefined)return
|
|
9
|
-
return process.env.EE_MODE = mode ? mode : 'framework';
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* 当前模式 - framework | module
|
|
14
|
-
*/
|
|
15
|
-
exports.mode = function() {
|
|
16
|
-
return process.env.EE_MODE;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 校验模式
|
|
21
|
-
*/
|
|
22
|
-
exports.verifyMode = function(mode) {
|
|
23
|
-
if (['framework', 'module'].includes(mode)) {
|
|
24
|
-
return true;
|
|
25
|
-
}
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
1
|
+
'use strict';
|
|
28
2
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
*/
|
|
32
|
-
exports.isFrameworkMode = function() {
|
|
33
|
-
return (process.env.EE_MODE === 'framework');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 是否为模块模式
|
|
38
|
-
*/
|
|
39
|
-
exports.isModuleMode = function() {
|
|
40
|
-
return (process.env.EE_MODE === 'module');
|
|
41
|
-
}
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const is = require('../utils/is');
|
|
42
5
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*/
|
|
46
|
-
exports.allEnv = function() {
|
|
6
|
+
// 当前进程的所有env
|
|
7
|
+
function allEnv() {
|
|
47
8
|
return process.env;
|
|
48
9
|
}
|
|
49
10
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
exports.env = function() {
|
|
54
|
-
return process.env.EE_SERVER_ENV;
|
|
11
|
+
// 当前环境 - local | prod
|
|
12
|
+
function env() {
|
|
13
|
+
return process.env.EE_ENV;
|
|
55
14
|
}
|
|
56
15
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
exports.getEnv = this.env
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* 是否生产环境
|
|
64
|
-
*/
|
|
65
|
-
exports.isProd = function() {
|
|
66
|
-
return (process.env.EE_SERVER_ENV === 'prod');
|
|
16
|
+
// 是否生产环境
|
|
17
|
+
function isProd() {
|
|
18
|
+
return (process.env.EE_ENV === 'prod');
|
|
67
19
|
}
|
|
68
20
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
exports.isDev = function() {
|
|
73
|
-
if ( process.env.EE_SERVER_ENV === 'development' ||
|
|
74
|
-
process.env.EE_SERVER_ENV === 'dev' ||
|
|
75
|
-
process.env.EE_SERVER_ENV === 'local'
|
|
76
|
-
) {
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if ( process.env.NODE_ENV === 'development' ||
|
|
81
|
-
process.env.NODE_ENV === 'dev' ||
|
|
82
|
-
process.env.NODE_ENV === 'local'
|
|
83
|
-
) {
|
|
21
|
+
// 是否为开发环境
|
|
22
|
+
function isDev() {
|
|
23
|
+
if (process.env.EE_ENV === 'dev' || process.env.EE_ENV === 'local') {
|
|
84
24
|
return true;
|
|
85
25
|
}
|
|
86
26
|
|
|
87
27
|
return false;
|
|
88
28
|
};
|
|
89
29
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*/
|
|
93
|
-
exports.isRenderer = function() {
|
|
30
|
+
// 是否为渲染进程
|
|
31
|
+
function isRenderer() {
|
|
94
32
|
return (typeof process === 'undefined' ||
|
|
95
33
|
!process ||
|
|
96
34
|
process.type === 'renderer');
|
|
97
35
|
};
|
|
98
36
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*/
|
|
102
|
-
exports.isMain = function() {
|
|
37
|
+
// 是否为主进程
|
|
38
|
+
function isMain() {
|
|
103
39
|
return ( typeof process !== 'undefined' &&
|
|
104
40
|
process.type === 'browser');
|
|
105
41
|
};
|
|
106
42
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
*/
|
|
110
|
-
exports.isForkedChild = function() {
|
|
43
|
+
// 是否为node子进程
|
|
44
|
+
function isForkedChild() {
|
|
111
45
|
return (Number(process.env.ELECTRON_RUN_AS_NODE) === 1);
|
|
112
46
|
};
|
|
113
47
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
*/
|
|
117
|
-
exports.processType = function() {
|
|
48
|
+
// 当前进程类型
|
|
49
|
+
function processType() {
|
|
118
50
|
let type = '';
|
|
119
|
-
if (
|
|
51
|
+
if (isMain()) {
|
|
120
52
|
type = 'browser';
|
|
121
|
-
} else if (
|
|
53
|
+
} else if (isRenderer()) {
|
|
122
54
|
type = 'renderer';
|
|
123
|
-
} else if (
|
|
55
|
+
} else if (isForkedChild()) {
|
|
124
56
|
type = 'child';
|
|
125
57
|
}
|
|
126
58
|
|
|
127
59
|
return type;
|
|
128
60
|
};
|
|
129
61
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
*/
|
|
133
|
-
exports.appName = function() {
|
|
62
|
+
// app name
|
|
63
|
+
function appName() {
|
|
134
64
|
return process.env.EE_APP_NAME;
|
|
135
65
|
}
|
|
136
66
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*/
|
|
140
|
-
exports.appVersion = function() {
|
|
67
|
+
// app version
|
|
68
|
+
function appVersion() {
|
|
141
69
|
return process.env.EE_APP_VERSION;
|
|
142
70
|
}
|
|
143
71
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* 获取数据存储路径
|
|
153
|
-
*/
|
|
154
|
-
exports.getStorageDir = function () {
|
|
155
|
-
const storageDir = path.join(this.getRootDir(), 'data');
|
|
156
|
-
return storageDir;
|
|
72
|
+
// 获取数据存储路径
|
|
73
|
+
function getDataDir() {
|
|
74
|
+
const base = isDev() ? getBaseDir() : getUserHomeHiddenAppDir();
|
|
75
|
+
const dataDir = path.join(base, 'data');
|
|
76
|
+
return dataDir;
|
|
157
77
|
}
|
|
158
78
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const dir = path.join(this.getRootDir(), 'logs');
|
|
79
|
+
// 获取日志存储路径
|
|
80
|
+
function getLogDir() {
|
|
81
|
+
const base = isDev() ? getBaseDir() : getUserHomeHiddenAppDir();
|
|
82
|
+
const dir = path.join(base, 'logs');
|
|
164
83
|
return dir;
|
|
165
84
|
}
|
|
166
85
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
*/
|
|
170
|
-
exports.getEncryptDir = function (basePath) {
|
|
86
|
+
// 获取bundle文件路径
|
|
87
|
+
function getBundleDir(basePath) {
|
|
171
88
|
const base = basePath || process.cwd();
|
|
172
89
|
const dir = path.join(base, 'public', 'electron');
|
|
173
90
|
return dir;
|
|
174
91
|
}
|
|
175
92
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
exports.getRootDir = function () {
|
|
180
|
-
const appDir = this.isDev() ? process.env.EE_HOME : process.env.EE_APP_USER_DATA;
|
|
93
|
+
// 获取root目录 (dev-项目根目录,pro-app user data目录)
|
|
94
|
+
function getRootDir() {
|
|
95
|
+
const appDir = isDev() ? getBaseDir() : getAppUserDataDir();
|
|
181
96
|
return appDir;
|
|
182
97
|
}
|
|
183
98
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
*/
|
|
187
|
-
exports.getBaseDir = function() {
|
|
99
|
+
// 获取base目录
|
|
100
|
+
function getBaseDir() {
|
|
188
101
|
return process.env.EE_BASE_DIR;
|
|
189
102
|
}
|
|
190
103
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
exports.getElectronDir = function() {
|
|
195
|
-
return process.env.EE_BASE_DIR;
|
|
104
|
+
// 获取electron目录
|
|
105
|
+
function getElectronDir() {
|
|
106
|
+
return process.env.EE_ELECTRON_DIR;
|
|
196
107
|
}
|
|
197
108
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
exports.getPublicDir = function() {
|
|
202
|
-
const dir = path.join(process.env.EE_HOME, "public");
|
|
109
|
+
// 获取public目录
|
|
110
|
+
function getPublicDir() {
|
|
111
|
+
const dir = path.join(getBaseDir(), "public");
|
|
203
112
|
return dir;
|
|
204
113
|
}
|
|
205
114
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
const execDir = this.getExecDir();
|
|
211
|
-
const isPackaged = this.isPackaged();
|
|
212
|
-
|
|
115
|
+
// 获取 额外资源目录
|
|
116
|
+
function getExtraResourcesDir() {
|
|
117
|
+
const execDir = getExecDir();
|
|
118
|
+
const packaged = isPackaged();
|
|
213
119
|
|
|
214
120
|
// 资源路径不同
|
|
215
121
|
let dir = '';
|
|
216
|
-
if (
|
|
122
|
+
if (packaged) {
|
|
217
123
|
// 打包后 execDir为 应用程序 exe\dmg\dep软件所在目录;打包前该值是项目根目录
|
|
218
124
|
// windows和MacOs不一样
|
|
219
125
|
dir = path.join(execDir, "resources", "extraResources");
|
|
220
|
-
if (
|
|
126
|
+
if (is.macOS()) {
|
|
221
127
|
dir = path.join(execDir, "..", "Resources", "extraResources");
|
|
222
128
|
}
|
|
223
129
|
} else {
|
|
@@ -227,105 +133,57 @@ exports.getExtraResourcesDir = function() {
|
|
|
227
133
|
return dir;
|
|
228
134
|
}
|
|
229
135
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
*/
|
|
233
|
-
exports.getAppUserDataDir = function() {
|
|
136
|
+
// 获取 appUserData目录
|
|
137
|
+
function getAppUserDataDir() {
|
|
234
138
|
return process.env.EE_APP_USER_DATA;
|
|
235
139
|
}
|
|
236
140
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
*/
|
|
240
|
-
exports.getExecDir = function() {
|
|
141
|
+
// 获取 exec目录
|
|
142
|
+
function getExecDir() {
|
|
241
143
|
return process.env.EE_EXEC_DIR;
|
|
242
144
|
}
|
|
243
145
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
*/
|
|
247
|
-
exports.getUserHomeDir = function() {
|
|
146
|
+
// 获取操作系统用户目录
|
|
147
|
+
function getUserHomeDir() {
|
|
248
148
|
return process.env.EE_USER_HOME;
|
|
249
149
|
}
|
|
250
150
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
// if (!fs.existsSync(filePath)) {
|
|
257
|
-
// throw new Error(filePath + ' is not found');
|
|
258
|
-
// }
|
|
259
|
-
// const pkg = JSON.parse(fs.readFileSync(filePath));
|
|
260
|
-
// if (!pkg.name || pkg.name == "") {
|
|
261
|
-
// throw new Error(`name is required from ${filePath}`);
|
|
262
|
-
// }
|
|
263
|
-
const appname = this.appName();
|
|
264
|
-
const cfgDir = path.join(this.getUserHomeDir(), ".config", appname);
|
|
265
|
-
return cfgDir;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* 获取基础数据路径
|
|
270
|
-
*/
|
|
271
|
-
exports.getUserHomeAppFilePath = function() {
|
|
272
|
-
const p = path.join(this.getUserHomeConfigDir(), "app.json");
|
|
273
|
-
return p;
|
|
151
|
+
// 获取用户家目录中的隐藏的app目录
|
|
152
|
+
function getUserHomeHiddenAppDir() {
|
|
153
|
+
const appnameDir = "." + appName();
|
|
154
|
+
const dir = path.join(getUserHomeDir(), appnameDir);
|
|
155
|
+
return dir;
|
|
274
156
|
}
|
|
275
157
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
return
|
|
158
|
+
// 获取用户家目录中的app目录
|
|
159
|
+
function getUserHomeAppDir() {
|
|
160
|
+
const appnameDir = appName();
|
|
161
|
+
const dir = path.join(getUserHomeDir(), appnameDir);
|
|
162
|
+
return dir;
|
|
281
163
|
}
|
|
282
164
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
*/
|
|
286
|
-
exports.getSocketPort = function () {
|
|
165
|
+
// 获取内置socket端口
|
|
166
|
+
function getSocketPort() {
|
|
287
167
|
return parseInt(process.env.EE_SOCKET_PORT) || 0;
|
|
288
168
|
}
|
|
289
169
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
*/
|
|
293
|
-
exports.getHttpPort = function () {
|
|
170
|
+
// 获取内置http端口
|
|
171
|
+
function getHttpPort() {
|
|
294
172
|
return parseInt(process.env.EE_HTTP_PORT) || 0;
|
|
295
173
|
}
|
|
296
174
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
*/
|
|
300
|
-
exports.isPackaged = function () {
|
|
175
|
+
// 是否打包
|
|
176
|
+
function isPackaged() {
|
|
301
177
|
return process.env.EE_IS_PACKAGED === 'true';
|
|
302
178
|
}
|
|
303
179
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
*/
|
|
307
|
-
exports.isEncrypted = function () {
|
|
308
|
-
return process.env.EE_IS_ENCRYPTED === 'true';
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* 是否热重启
|
|
313
|
-
*/
|
|
314
|
-
exports.isHotReload = function () {
|
|
315
|
-
return process.env.HOT_RELOAD === 'true';
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/**
|
|
319
|
-
* 进程退出
|
|
320
|
-
*/
|
|
321
|
-
exports.exit = function(code = 0) {
|
|
180
|
+
// 进程退出
|
|
181
|
+
function exit(code = 0) {
|
|
322
182
|
return process.exit(code);
|
|
323
183
|
}
|
|
324
184
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
*/
|
|
328
|
-
exports.makeMessage = function(msg = {}) {
|
|
185
|
+
// 格式化message
|
|
186
|
+
function makeMessage(msg = {}) {
|
|
329
187
|
let message = Object.assign({
|
|
330
188
|
channel: '',
|
|
331
189
|
event: '',
|
|
@@ -335,10 +193,8 @@ exports.makeMessage = function(msg = {}) {
|
|
|
335
193
|
return message;
|
|
336
194
|
}
|
|
337
195
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
*/
|
|
341
|
-
exports.exitChildJob = function(code = 0) {
|
|
196
|
+
// 退出ChildJob进程
|
|
197
|
+
function exitChildJob(code = 0) {
|
|
342
198
|
try {
|
|
343
199
|
let args = JSON.parse(process.argv[2]);
|
|
344
200
|
if (args.type == 'childJob') {
|
|
@@ -349,11 +205,8 @@ exports.exitChildJob = function(code = 0) {
|
|
|
349
205
|
}
|
|
350
206
|
}
|
|
351
207
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
* 任务类型 ChildJob
|
|
355
|
-
*/
|
|
356
|
-
exports.isChildJob = function() {
|
|
208
|
+
// 任务类型 ChildJob
|
|
209
|
+
function isChildJob() {
|
|
357
210
|
try {
|
|
358
211
|
let args = JSON.parse(process.argv[2]);
|
|
359
212
|
if (args.type == 'childJob') {
|
|
@@ -364,10 +217,8 @@ exports.isChildJob = function() {
|
|
|
364
217
|
}
|
|
365
218
|
}
|
|
366
219
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
*/
|
|
370
|
-
exports.isChildPoolJob = function() {
|
|
220
|
+
// 任务类型 ChildPoolJob
|
|
221
|
+
function isChildPoolJob() {
|
|
371
222
|
try {
|
|
372
223
|
let args = JSON.parse(process.argv[2]);
|
|
373
224
|
if (args.type == 'childPoolJob') {
|
|
@@ -376,4 +227,50 @@ exports.isChildPoolJob = function() {
|
|
|
376
227
|
} catch (e) {
|
|
377
228
|
return false;
|
|
378
229
|
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Get cmd parameter by name
|
|
233
|
+
function getArgumentByName(name) {
|
|
234
|
+
for (let i = 0; i < process.argv.length; i++) {
|
|
235
|
+
const item = process.argv[i]
|
|
236
|
+
const prefixKey = `--${name}=`;
|
|
237
|
+
if (item.indexOf(prefixKey) !== -1) {
|
|
238
|
+
return item.substring(prefixKey.length);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
module.exports = {
|
|
244
|
+
allEnv,
|
|
245
|
+
env,
|
|
246
|
+
isProd,
|
|
247
|
+
isDev,
|
|
248
|
+
isRenderer,
|
|
249
|
+
isMain,
|
|
250
|
+
isForkedChild,
|
|
251
|
+
processType,
|
|
252
|
+
appName,
|
|
253
|
+
appVersion,
|
|
254
|
+
getDataDir,
|
|
255
|
+
getLogDir,
|
|
256
|
+
getBundleDir,
|
|
257
|
+
getRootDir,
|
|
258
|
+
getBaseDir,
|
|
259
|
+
getElectronDir,
|
|
260
|
+
getPublicDir,
|
|
261
|
+
getExtraResourcesDir,
|
|
262
|
+
getAppUserDataDir,
|
|
263
|
+
getExecDir,
|
|
264
|
+
getUserHomeDir,
|
|
265
|
+
getUserHomeAppDir,
|
|
266
|
+
getUserHomeHiddenAppDir,
|
|
267
|
+
getSocketPort,
|
|
268
|
+
getHttpPort,
|
|
269
|
+
isPackaged,
|
|
270
|
+
exit,
|
|
271
|
+
makeMessage,
|
|
272
|
+
exitChildJob,
|
|
273
|
+
isChildJob,
|
|
274
|
+
isChildPoolJob,
|
|
275
|
+
getArgumentByName
|
|
379
276
|
}
|