ee-core 1.1.7 → 1.1.10
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 +10 -1
- package/lib/eeApp.js +3 -3
- package/lib/socket/io.js +3 -1
- package/lib/socket/socketServer.js +2 -1
- package/package.json +2 -1
- package/utils/index.js +29 -0
package/config/config.default.js
CHANGED
|
@@ -194,7 +194,16 @@ module.exports = appInfo => {
|
|
|
194
194
|
/* 内置socket服务 */
|
|
195
195
|
config.socketServer = {
|
|
196
196
|
port: 7070, // 默认端口
|
|
197
|
-
isDynamic: false // 如果值为false,框架默认使用port端口(如果默认端口被使用,则随机获取一个);如果为true,默认端口无效,框架随机生成
|
|
197
|
+
isDynamic: false, // 如果值为false,框架默认使用port端口(如果默认端口被使用,则随机获取一个);如果为true,默认端口无效,框架随机生成
|
|
198
|
+
path: "/socket.io/", // 路径名称
|
|
199
|
+
connectTimeout: 45000, // 客户端连接超时时间
|
|
200
|
+
pingTimeout: 30000, // 心跳检测超时时间
|
|
201
|
+
pingInterval: 25000, // 心跳检测间隔
|
|
202
|
+
maxHttpBufferSize: 1e8, // 每条消息的数据大小 1M
|
|
203
|
+
transports: ["polling", "websocket"], // http轮询和websocket
|
|
204
|
+
cors: {
|
|
205
|
+
origin: true, // http协议时,要设置跨域 类型 Boolean String RegExp Array Function
|
|
206
|
+
}
|
|
198
207
|
};
|
|
199
208
|
|
|
200
209
|
return config;
|
package/lib/eeApp.js
CHANGED
|
@@ -26,8 +26,8 @@ class EeApp extends BaseApp {
|
|
|
26
26
|
|
|
27
27
|
process.env.EE_SOCKET_PORT = socketPort;
|
|
28
28
|
process.env.EE_WEB_PORT = webPort;
|
|
29
|
-
this.coreLogger.info('[ee-core:EeApp] [createPorts] socket port:', socketPort);
|
|
30
|
-
this.coreLogger.info('[ee-core:EeApp] [createPorts] web port:', webPort);
|
|
29
|
+
//this.coreLogger.info('[ee-core:EeApp] [createPorts] socket port:', socketPort);
|
|
30
|
+
//this.coreLogger.info('[ee-core:EeApp] [createPorts] web port:', webPort);
|
|
31
31
|
|
|
32
32
|
// 更新db配置
|
|
33
33
|
this.config.socketServer.port = socketPort;
|
|
@@ -206,7 +206,7 @@ class EeApp extends BaseApp {
|
|
|
206
206
|
* 主页面
|
|
207
207
|
*/
|
|
208
208
|
loadMainUrl (type, url) {
|
|
209
|
-
this.logger.info('main page is env: %s, type: %s,
|
|
209
|
+
this.logger.info('main page is env: %s, type: %s, App running at: %s', this.config.env, type, url);
|
|
210
210
|
this.electron.mainWindow.loadURL(url);
|
|
211
211
|
}
|
|
212
212
|
|
package/lib/socket/io.js
CHANGED
|
@@ -4,6 +4,7 @@ const IoServer = require('socket.io');
|
|
|
4
4
|
const IoClient = require('socket.io-client');
|
|
5
5
|
//const socketServer = require('./socketServer');
|
|
6
6
|
const socketClient = require('./socketClient');
|
|
7
|
+
const Koa = require('koa');
|
|
7
8
|
|
|
8
9
|
const EeSocket = {
|
|
9
10
|
getServer: () => {
|
|
@@ -18,5 +19,6 @@ const EeSocket = {
|
|
|
18
19
|
module.exports = {
|
|
19
20
|
IoServer,
|
|
20
21
|
IoClient,
|
|
21
|
-
EeSocket
|
|
22
|
+
EeSocket,
|
|
23
|
+
Koa
|
|
22
24
|
};
|
|
@@ -18,7 +18,8 @@ class SocketServer {
|
|
|
18
18
|
this.app = app;
|
|
19
19
|
this.consoleLogger = new EggConsoleLogger();
|
|
20
20
|
this.consoleLogger.info('[ee-core:socket:server] start server, socket port is:', port);
|
|
21
|
-
|
|
21
|
+
const options = this.app.config.socketServer;
|
|
22
|
+
this.io = new Server(port, options);
|
|
22
23
|
this.connec();
|
|
23
24
|
}
|
|
24
25
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ee-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"description": "ee core",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"agentkeepalive": "^4.2.0",
|
|
16
|
+
"co": "^4.6.0",
|
|
16
17
|
"egg-errors": "^2.3.0",
|
|
17
18
|
"egg-logger": "^2.7.1",
|
|
18
19
|
"electron-is": "^3.0.0",
|
package/utils/index.js
CHANGED
|
@@ -8,6 +8,9 @@ const is = require('is-type-of');
|
|
|
8
8
|
const co = require('co');
|
|
9
9
|
const utility = require('utility');
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* 创建文件夹
|
|
13
|
+
*/
|
|
11
14
|
exports.mkdir = function(dirpath, dirname) {
|
|
12
15
|
// 判断是否是第一次调用
|
|
13
16
|
if (typeof dirname === 'undefined') {
|
|
@@ -30,6 +33,9 @@ exports.mkdir = function(dirpath, dirname) {
|
|
|
30
33
|
}
|
|
31
34
|
};
|
|
32
35
|
|
|
36
|
+
/**
|
|
37
|
+
* 修改文件权限
|
|
38
|
+
*/
|
|
33
39
|
exports.chmodPath = function(path, mode) {
|
|
34
40
|
let files = [];
|
|
35
41
|
if (fs.existsSync(path)) {
|
|
@@ -131,6 +137,29 @@ exports.getSocketChannel = function() {
|
|
|
131
137
|
return constant.socketIo.channel;
|
|
132
138
|
}
|
|
133
139
|
|
|
140
|
+
/**
|
|
141
|
+
* 获取 额外资源目录
|
|
142
|
+
*/
|
|
143
|
+
exports.getExtraResourcesDir = function() {
|
|
144
|
+
const cdb = this.getCoreDB();
|
|
145
|
+
const config = cdb.getItem('config');
|
|
146
|
+
const execDir = config.execDir;
|
|
147
|
+
|
|
148
|
+
// 资源路径不同
|
|
149
|
+
let dir = '';
|
|
150
|
+
if (config.isPackaged) {
|
|
151
|
+
// 打包后 execDir为 应用程序 exe\dmg\dep软件所在目录;打包前该值是项目根目录
|
|
152
|
+
dir = path.join(execDir, "resources", "extraResources");
|
|
153
|
+
} else {
|
|
154
|
+
// 打包前
|
|
155
|
+
dir = path.join(execDir, "build", "extraResources");
|
|
156
|
+
}
|
|
157
|
+
return dir;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* 执行一个函数
|
|
162
|
+
*/
|
|
134
163
|
exports.callFn = async function (fn, args, ctx) {
|
|
135
164
|
args = args || [];
|
|
136
165
|
if (!is.function(fn)) return;
|