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.
@@ -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
  };
@@ -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.EE_EGG_PORT = null;
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 eggPort = this.config.env === 'prod' ? await getPort() : this.config.egg.port;
25
- this.config.egg.port = eggPort;
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.EE_EGG_PORT = eggPort;
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] egg port:', eggPort);
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.EE_EGG_PORT;
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
- // egg服务是否开启
156
- if (this.config.egg.enable == false) {
157
- return;
158
- }
159
- let eggConfig = this.config.egg;
160
- const protocol = 'http://';
161
- let startRes = null;
162
- let url = protocol + eggConfig.hostname + ':' + eggConfig.port;
163
-
164
- startRes = await this.startEgg(eggConfig).then((res) => res, (err) => err);
165
- this.coreLogger.info('[ee-core:EeApp] [startEggServer] startRes:', startRes)
166
- if (startRes === 'success') {
167
- // 如果加载远程网址,则不能重复load
168
- const remoteConfig = this.config.remoteUrl;
169
- if (remoteConfig.enable) {
170
- return;
171
- }
172
- this.loadMainUrl('egg', url);
173
- } else {
174
- // 失败后重启
175
- app.relaunch();
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
- let homeDir = this.homeDir;
240
- argv.baseDir = homeDir;
241
- argv.framework = path.join(homeDir, 'node_modules', 'egg');
242
-
243
- const appName = this.config.name;
244
- argv.title = argv.title || `egg-server-${appName}`;
245
-
246
-
247
- // normalize env
248
- // 目前没有用到,不用修改;想要修改的话,区分打包前后的路径?
249
- // env.HOME = HOME; // 这个home不能修改,因为自动升级功能会用到(win没有问题,mac有权限问题)
250
- //env.NODE_ENV = 'production';
251
-
252
- // 更新缓存配置
253
- this.getCoreDB().setItem('config', this.config);
254
-
255
- const ignoreKeys = [ '_', '$0', 'env', 'daemon', 'stdout', 'stderr', 'timeout', 'ignore-stderr', 'node' ];
256
- const clusterOptions = this.stringify(argv, ignoreKeys);
257
- const options = JSON.parse(clusterOptions);
258
- this.coreLogger.info('[ee-core:EeApp] [startEgg] options', options);
259
-
260
- return new Promise((resolve, reject) => {
261
- startCluster(options, function(){
262
- resolve('success');
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.2",
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",