ee-core 1.1.2 → 1.1.5
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/config/config.default.js +14 -0
- package/lib/application.js +1 -1
- package/lib/eeApp.js +55 -65
- package/package.json +2 -2
package/config/config.default.js
CHANGED
|
@@ -175,5 +175,19 @@ module.exports = appInfo => {
|
|
|
175
175
|
},
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
+
/* egg服务 (待定) */
|
|
179
|
+
config.egg = {
|
|
180
|
+
enable: false, // 是否启用
|
|
181
|
+
title: 'ee', // 进程的title属性标识(默认你的应用名称-英文)
|
|
182
|
+
port: 7068,
|
|
183
|
+
hostname: '127.0.0.1',
|
|
184
|
+
workers: 1 // 工作进程数据
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/* web渲染服务 */
|
|
188
|
+
config.webServer = {
|
|
189
|
+
port: 7068
|
|
190
|
+
};
|
|
191
|
+
|
|
178
192
|
return config;
|
|
179
193
|
};
|
package/lib/application.js
CHANGED
|
@@ -46,7 +46,7 @@ class Appliaction extends EeApp {
|
|
|
46
46
|
env.EE_USER_HOME = options.userHome;
|
|
47
47
|
env.EE_APP_DATA = options.appData;
|
|
48
48
|
env.EE_APP_USER_DATA = options.appUserData;
|
|
49
|
-
env.
|
|
49
|
+
env.EE_WEB_PORT = null;
|
|
50
50
|
env.EE_IPC_PORT = null;
|
|
51
51
|
env.EGG_SERVER_ENV = options.env;
|
|
52
52
|
debug('options:%j', options)
|
package/lib/eeApp.js
CHANGED
|
@@ -21,12 +21,12 @@ class EeApp extends BaseApp {
|
|
|
21
21
|
*/
|
|
22
22
|
async createPorts () {
|
|
23
23
|
const ipcPort = await getPort();
|
|
24
|
-
const
|
|
25
|
-
this.config.
|
|
24
|
+
const webPort = this.config.env === 'prod' ? await getPort() : this.config.webServer.port;
|
|
25
|
+
this.config.webServer.port = webPort;
|
|
26
26
|
process.env.EE_IPC_PORT = ipcPort;
|
|
27
|
-
process.env.
|
|
27
|
+
process.env.EE_WEB_PORT = webPort;
|
|
28
28
|
this.coreLogger.info('[ee-core:EeApp] [createPorts] ipc port:', ipcPort);
|
|
29
|
-
this.coreLogger.info('[ee-core:EeApp] [createPorts]
|
|
29
|
+
this.coreLogger.info('[ee-core:EeApp] [createPorts] web port:', webPort);
|
|
30
30
|
|
|
31
31
|
// 更新db配置
|
|
32
32
|
this.getCoreDB().setItem('ipc_port', ipcPort);
|
|
@@ -82,7 +82,7 @@ class EeApp extends BaseApp {
|
|
|
82
82
|
this.electron.mainWindow = new BrowserWindow(winOptions);
|
|
83
83
|
|
|
84
84
|
// 隐藏菜单
|
|
85
|
-
if (this.config.openAppMenu) {
|
|
85
|
+
if (!this.config.openAppMenu) {
|
|
86
86
|
Menu.setApplicationMenu(null);
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -95,8 +95,6 @@ class EeApp extends BaseApp {
|
|
|
95
95
|
await this.loderPreload();
|
|
96
96
|
|
|
97
97
|
this.loadLocalWeb();
|
|
98
|
-
|
|
99
|
-
await this.startEggServer();
|
|
100
98
|
|
|
101
99
|
// DevTools
|
|
102
100
|
if (!app.isPackaged && this.config.openDevTools) {
|
|
@@ -124,16 +122,12 @@ class EeApp extends BaseApp {
|
|
|
124
122
|
return;
|
|
125
123
|
}
|
|
126
124
|
|
|
127
|
-
// 如果egg服务开启,则不能加载本地的
|
|
128
|
-
if (this.config.egg.enable == true) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
125
|
const self = this;
|
|
132
126
|
const staticDir = path.join(this.config.homeDir, 'public', 'dist');
|
|
133
127
|
|
|
134
128
|
const koaApp = new Koa();
|
|
135
129
|
koaApp.use(koaServe(staticDir))
|
|
136
|
-
const port = process.env.
|
|
130
|
+
const port = process.env.EE_WEB_PORT;
|
|
137
131
|
koaApp.listen(port, () => {
|
|
138
132
|
const url = 'http://127.0.0.1:' + port;
|
|
139
133
|
self.loadMainUrl('local_web', url);
|
|
@@ -151,30 +145,30 @@ class EeApp extends BaseApp {
|
|
|
151
145
|
/**
|
|
152
146
|
* 创建egg服务
|
|
153
147
|
*/
|
|
154
|
-
async startEggServer () {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
148
|
+
// async startEggServer () {
|
|
149
|
+
// // egg服务是否开启
|
|
150
|
+
// if (this.config.egg.enable == false) {
|
|
151
|
+
// return;
|
|
152
|
+
// }
|
|
153
|
+
// let eggConfig = this.config.egg;
|
|
154
|
+
// const protocol = 'http://';
|
|
155
|
+
// let startRes = null;
|
|
156
|
+
// let url = protocol + eggConfig.hostname + ':' + eggConfig.port;
|
|
157
|
+
|
|
158
|
+
// startRes = await this.startEgg(eggConfig).then((res) => res, (err) => err);
|
|
159
|
+
// this.coreLogger.info('[ee-core:EeApp] [startEggServer] startRes:', startRes)
|
|
160
|
+
// if (startRes === 'success') {
|
|
161
|
+
// // 如果加载远程网址,则不能重复load
|
|
162
|
+
// const remoteConfig = this.config.remoteUrl;
|
|
163
|
+
// if (remoteConfig.enable) {
|
|
164
|
+
// return;
|
|
165
|
+
// }
|
|
166
|
+
// this.loadMainUrl('egg', url);
|
|
167
|
+
// } else {
|
|
168
|
+
// // 失败后重启
|
|
169
|
+
// app.relaunch();
|
|
170
|
+
// }
|
|
171
|
+
// }
|
|
178
172
|
|
|
179
173
|
/**
|
|
180
174
|
* 加载loading页面
|
|
@@ -233,36 +227,32 @@ class EeApp extends BaseApp {
|
|
|
233
227
|
/**
|
|
234
228
|
* egg
|
|
235
229
|
*/
|
|
236
|
-
startEgg (argv) {
|
|
237
|
-
const startCluster = require('egg-cluster').startCluster;
|
|
230
|
+
// startEgg (argv) {
|
|
238
231
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
});
|
|
264
|
-
});
|
|
265
|
-
}
|
|
232
|
+
// let homeDir = this.homeDir;
|
|
233
|
+
// argv.baseDir = homeDir;
|
|
234
|
+
// argv.framework = path.join(homeDir, 'node_modules', 'egg');
|
|
235
|
+
|
|
236
|
+
// const appName = this.config.name;
|
|
237
|
+
// argv.title = argv.title || `egg-server-${appName}`;
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
// // normalize env
|
|
241
|
+
// // 目前没有用到,不用修改;想要修改的话,区分打包前后的路径?
|
|
242
|
+
// // env.HOME = HOME; // 这个home不能修改,因为自动升级功能会用到(win没有问题,mac有权限问题)
|
|
243
|
+
// //env.NODE_ENV = 'production';
|
|
244
|
+
|
|
245
|
+
// // 更新缓存配置
|
|
246
|
+
// this.getCoreDB().setItem('config', this.config);
|
|
247
|
+
|
|
248
|
+
// const ignoreKeys = [ '_', '$0', 'env', 'daemon', 'stdout', 'stderr', 'timeout', 'ignore-stderr', 'node' ];
|
|
249
|
+
// const clusterOptions = this.stringify(argv, ignoreKeys);
|
|
250
|
+
// const options = JSON.parse(clusterOptions);
|
|
251
|
+
// this.coreLogger.info('[ee-core:EeApp] [startEgg] options', options);
|
|
252
|
+
// if (is.function(this.startEggCluster)) {
|
|
253
|
+
// return this.startEggCluster(options);
|
|
254
|
+
// }
|
|
255
|
+
// }
|
|
266
256
|
|
|
267
257
|
/**
|
|
268
258
|
* 限制一个窗口
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ee-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"description": "ee core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"agentkeepalive": "^4.2.0",
|
|
16
|
-
"egg-cluster": "^1.27.1",
|
|
17
16
|
"egg-errors": "^2.3.0",
|
|
18
17
|
"egg-logger": "^2.7.1",
|
|
19
18
|
"electron-is": "^3.0.0",
|
|
20
19
|
"electron-updater": "^4.6.1",
|
|
20
|
+
"extend2": "^1.0.1",
|
|
21
21
|
"fs-extra": "^10.0.0",
|
|
22
22
|
"get-port": "^5.1.1",
|
|
23
23
|
"globby": "^10.0.0",
|