mm_os 2.1.1 → 2.1.3
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/core/com/api/drive.js +2 -2
- package/core/com/db/index.js +1 -1
- package/core/com/event/index.js +1 -1
- package/core/com/mqtt/index.js +2 -2
- package/core/com/nav/index.js +1 -1
- package/core/com/param/index.js +1 -1
- package/core/com/socket/index.js +1 -1
- package/core/com/sql/drive.js +5 -5
- package/core/com/sql/index.js +1 -1
- package/core/com/tpl/com.js +2 -2
- package/demo/app/test/app.json +3 -0
- package/demo/app/test/event_api/client/event.json +18 -0
- package/demo/app/test/event_api/client/main.js +21 -0
- package/demo/config/development.json +99 -0
- package/demo/config/local.json +99 -0
- package/demo/config/test.json +99 -0
- package/demo/index.js +14 -0
- package/index.js +21 -14
- package/lib/app.js +1 -3
- package/lib/base.js +2 -4
- package/lib/com.js +1 -3
- package/lib/game.js +1 -3
- package/package.json +16 -16
package/core/com/api/drive.js
CHANGED
|
@@ -27,8 +27,8 @@ class Drive extends Item {
|
|
|
27
27
|
super(dir, __dirname);
|
|
28
28
|
this.default_file = "./api.json";
|
|
29
29
|
|
|
30
|
-
this.save_dir = '
|
|
31
|
-
this.url_path = "
|
|
30
|
+
this.save_dir = './static/file/';
|
|
31
|
+
this.url_path = "./file/";
|
|
32
32
|
|
|
33
33
|
// oauth身份验证配置 + 函数
|
|
34
34
|
this.oauth;
|
package/core/com/db/index.js
CHANGED
package/core/com/event/index.js
CHANGED
package/core/com/mqtt/index.js
CHANGED
|
@@ -86,7 +86,7 @@ MQTT.prototype.run = async function(conn) {
|
|
|
86
86
|
*/
|
|
87
87
|
MQTT.prototype.load = function(path) {
|
|
88
88
|
if (!path) {
|
|
89
|
-
path = "
|
|
89
|
+
path = "./mqtt/";
|
|
90
90
|
}
|
|
91
91
|
// 获取所有应用路径
|
|
92
92
|
var list_scope = $.dir.getAll(path, "mqtt");
|
|
@@ -137,4 +137,4 @@ function mqtt_admin(scope, title) {
|
|
|
137
137
|
* @return {Object} 返回一个缓存类
|
|
138
138
|
*/
|
|
139
139
|
$.mqtt_admin = mqtt_admin;
|
|
140
|
-
|
|
140
|
+
|
package/core/com/nav/index.js
CHANGED
package/core/com/param/index.js
CHANGED
package/core/com/socket/index.js
CHANGED
package/core/com/sql/drive.js
CHANGED
|
@@ -16,7 +16,7 @@ class Drive extends Item {
|
|
|
16
16
|
super(dir, __dirname);
|
|
17
17
|
this.default_file = "./sql.json";
|
|
18
18
|
// 保存文件目录
|
|
19
|
-
this.save_dir = '
|
|
19
|
+
this.save_dir = './file/';
|
|
20
20
|
// 读取文件目录
|
|
21
21
|
this.url_path = "/file/";
|
|
22
22
|
|
|
@@ -663,11 +663,11 @@ Drive.prototype.import_main = async function(db, file) {
|
|
|
663
663
|
if ($.config.path) {
|
|
664
664
|
path = $.config.path.user || $.config.path.static || "/static/";
|
|
665
665
|
} else {
|
|
666
|
-
path = "
|
|
666
|
+
path = "./static/";
|
|
667
667
|
}
|
|
668
668
|
file = file.fullname(path);
|
|
669
669
|
}
|
|
670
|
-
|
|
670
|
+
|
|
671
671
|
if (!file.hasFile()) {
|
|
672
672
|
return $.ret.error(30001, file + "文件不存在!");
|
|
673
673
|
}
|
|
@@ -782,12 +782,11 @@ Drive.prototype.export_main = async function(db, query, body) {
|
|
|
782
782
|
if ($.config.path) {
|
|
783
783
|
path = $.config.path.user || $.config.path.static || "/static/";
|
|
784
784
|
} else {
|
|
785
|
-
path = "
|
|
785
|
+
path = "./static/";
|
|
786
786
|
}
|
|
787
787
|
}
|
|
788
788
|
if (!file) {
|
|
789
789
|
file = this.save_dir + name;
|
|
790
|
-
file.addDir(path);
|
|
791
790
|
}
|
|
792
791
|
if (!fields && query.field) {
|
|
793
792
|
fields = query.field;
|
|
@@ -795,6 +794,7 @@ Drive.prototype.export_main = async function(db, query, body) {
|
|
|
795
794
|
var params = await this.get_params(db, fields);
|
|
796
795
|
var format = await this.get_format(db);
|
|
797
796
|
file = file.fullname(path);
|
|
797
|
+
file.addDir();
|
|
798
798
|
var excel = new Excel({
|
|
799
799
|
file,
|
|
800
800
|
params,
|
package/core/com/sql/index.js
CHANGED
package/core/com/tpl/com.js
CHANGED
|
@@ -8,11 +8,11 @@ class Controller extends Base {
|
|
|
8
8
|
super();
|
|
9
9
|
|
|
10
10
|
// 检索的文件路径
|
|
11
|
-
this.path = "
|
|
11
|
+
this.path = "./apps/controller".fullname();
|
|
12
12
|
// 文件拓展名
|
|
13
13
|
this.extension = "controller.json";
|
|
14
14
|
// 文件存放目录
|
|
15
|
-
this.dir = "
|
|
15
|
+
this.dir = "./apps";
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[{
|
|
2
|
+
// 目标对象
|
|
3
|
+
"target": "/api/test*",
|
|
4
|
+
// 事件名称, 用于动态增删改
|
|
5
|
+
"name": "test_client",
|
|
6
|
+
// 标题, 用于开发者查看事件
|
|
7
|
+
"title": "示例事件",
|
|
8
|
+
// 描述, 用于介绍该事件是做什么用的
|
|
9
|
+
"description": "描述事件使用方法",
|
|
10
|
+
// 阶段, 分执行前before、验证check、主要main、渲染render、执行后after阶段
|
|
11
|
+
"stage": "main",
|
|
12
|
+
// 响应方法 GET请求、POST请求、ALL所有请求,如果非API事件可自定义
|
|
13
|
+
"method": "ALL",
|
|
14
|
+
// 函数文件, 当事件触发时执行指定的脚本
|
|
15
|
+
"func_file": "./main.js",
|
|
16
|
+
// 执行顺序, 数值越小越优先执行
|
|
17
|
+
"sort": 100
|
|
18
|
+
}]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// 使用api管理器
|
|
2
|
+
var api = $.api_admin('test_client', 'test_client');
|
|
3
|
+
// 首次启动更新api接口;
|
|
4
|
+
api.update();
|
|
5
|
+
|
|
6
|
+
// 使用mysql数据库管理器
|
|
7
|
+
var sql = $.mysql_admin('sys', __dirname);
|
|
8
|
+
// sql.setConfig($.config.mysql);
|
|
9
|
+
// sql.open();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @description 接口主函数
|
|
13
|
+
* @param {Object} ctx HTTP上下文
|
|
14
|
+
* @param {Object} db 数据管理器,如: { next: async function{}, ret: {} }
|
|
15
|
+
* @return {Object} 执行结果
|
|
16
|
+
*/
|
|
17
|
+
async function main(ctx, db) {
|
|
18
|
+
return "你好"
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.main = main;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sys": {
|
|
3
|
+
// 服务端名称
|
|
4
|
+
"name": "mm",
|
|
5
|
+
// 服务端中文名
|
|
6
|
+
"title": "超级美眉",
|
|
7
|
+
// 缓存方式 memory redis mongodb
|
|
8
|
+
"cache": "redis",
|
|
9
|
+
// 系统使用的语言
|
|
10
|
+
"lang": "zh_CN",
|
|
11
|
+
// 定时任务
|
|
12
|
+
"task": false,
|
|
13
|
+
// 热重载
|
|
14
|
+
"hot_reload": false
|
|
15
|
+
},
|
|
16
|
+
"web": {
|
|
17
|
+
"state": true,
|
|
18
|
+
// 访问地址
|
|
19
|
+
"host": "0.0.0.0",
|
|
20
|
+
// 访问端口号
|
|
21
|
+
"port": 8000,
|
|
22
|
+
// 是否启用websocket
|
|
23
|
+
"socket": false,
|
|
24
|
+
// 是否启用压缩
|
|
25
|
+
"compress": false,
|
|
26
|
+
// 是否启用事件
|
|
27
|
+
"event": true,
|
|
28
|
+
// 是否启用日志
|
|
29
|
+
"log": true,
|
|
30
|
+
// 是否启用静态文件
|
|
31
|
+
"static": true,
|
|
32
|
+
// 静态文件路径
|
|
33
|
+
"static_path": "./static",
|
|
34
|
+
// 静态文件缓存时长
|
|
35
|
+
"max_age": 120000,
|
|
36
|
+
// 代理转发
|
|
37
|
+
"proxy": {}
|
|
38
|
+
},
|
|
39
|
+
"mqtt": {
|
|
40
|
+
// 是否启用MQTT
|
|
41
|
+
"state": false,
|
|
42
|
+
// mqtt访问端口号
|
|
43
|
+
"socket_port": 1883,
|
|
44
|
+
// websocket 访问端口
|
|
45
|
+
"http_port": 8083,
|
|
46
|
+
// 缓存方式
|
|
47
|
+
"cache": "memory",
|
|
48
|
+
// 缓存服务器地址
|
|
49
|
+
"cache_host": "mongodb://localhost:27017/mosca",
|
|
50
|
+
// MQTT订阅方式
|
|
51
|
+
"subscribe_qos": 0,
|
|
52
|
+
// 协议头
|
|
53
|
+
"protocol": "mqtt",
|
|
54
|
+
// MQTT服务器地址
|
|
55
|
+
"hostname": "mqtt.aieliantong.com",
|
|
56
|
+
// MQTT服务器用户名
|
|
57
|
+
"username": "developer",
|
|
58
|
+
// MQTT服务器密码
|
|
59
|
+
"password": "asd123",
|
|
60
|
+
// MQTT端口号
|
|
61
|
+
"port": 1883
|
|
62
|
+
},
|
|
63
|
+
"mysql": {
|
|
64
|
+
// 服务器地址
|
|
65
|
+
"host": "127.0.0.1",
|
|
66
|
+
// 端口号
|
|
67
|
+
"port": 3306,
|
|
68
|
+
// 用户名
|
|
69
|
+
"user": "root",
|
|
70
|
+
// 密码
|
|
71
|
+
"password": "Asd159357",
|
|
72
|
+
// 数据库名称
|
|
73
|
+
"database": "face"
|
|
74
|
+
},
|
|
75
|
+
"redis": {
|
|
76
|
+
// 服务器地址
|
|
77
|
+
"host": "127.0.0.1",
|
|
78
|
+
// 端口号
|
|
79
|
+
"port": 6379,
|
|
80
|
+
// 密码
|
|
81
|
+
"password": "asd159357",
|
|
82
|
+
// 选用的数据库0-9
|
|
83
|
+
"database": 0,
|
|
84
|
+
// 键前缀
|
|
85
|
+
"prefix": "mm_"
|
|
86
|
+
},
|
|
87
|
+
"mongodb": {
|
|
88
|
+
// 服务器地址
|
|
89
|
+
"host": "localhost",
|
|
90
|
+
// 端口号
|
|
91
|
+
"port": 27017,
|
|
92
|
+
// 数据库名
|
|
93
|
+
"database": "mqtt",
|
|
94
|
+
// 用户名
|
|
95
|
+
"user": "mqtt",
|
|
96
|
+
// 密码 无则代表连接不需要账号密码
|
|
97
|
+
"password": "asd123"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sys": {
|
|
3
|
+
// 服务端名称
|
|
4
|
+
"name": "mm",
|
|
5
|
+
// 服务端中文名
|
|
6
|
+
"title": "超级美眉",
|
|
7
|
+
// 缓存方式
|
|
8
|
+
"cache": "redis",
|
|
9
|
+
// 系统使用的语言
|
|
10
|
+
"lang": "zh_CN",
|
|
11
|
+
// 定时任务
|
|
12
|
+
"task": true,
|
|
13
|
+
// 热重载
|
|
14
|
+
"hot_reload": true
|
|
15
|
+
},
|
|
16
|
+
"web": {
|
|
17
|
+
"state": true,
|
|
18
|
+
// 访问地址
|
|
19
|
+
"host": "0.0.0.0",
|
|
20
|
+
// 访问端口号
|
|
21
|
+
"port": 8000,
|
|
22
|
+
// 是否启用websocket
|
|
23
|
+
"socket": true,
|
|
24
|
+
// 是否启用压缩
|
|
25
|
+
"compress": true,
|
|
26
|
+
// 是否启用事件
|
|
27
|
+
"event": true,
|
|
28
|
+
// 是否启用事件
|
|
29
|
+
"log": true,
|
|
30
|
+
// 是否启用静态文件
|
|
31
|
+
"static": true,
|
|
32
|
+
// 静态文件路径
|
|
33
|
+
"static_path": "./static",
|
|
34
|
+
// 静态文件缓存时长
|
|
35
|
+
"max_age": 3600,
|
|
36
|
+
// 代理转发
|
|
37
|
+
"proxy": {}
|
|
38
|
+
},
|
|
39
|
+
"mqtt": {
|
|
40
|
+
"state": false,
|
|
41
|
+
// mqtt访问端口号
|
|
42
|
+
"socket_port": 1883,
|
|
43
|
+
// 服务端
|
|
44
|
+
"http_host": "localhost",
|
|
45
|
+
// websocket 访问端口
|
|
46
|
+
"http_port": 8083,
|
|
47
|
+
// 缓存方式
|
|
48
|
+
"cache": "mongodb",
|
|
49
|
+
// 缓存服务器地址
|
|
50
|
+
"cache_host": "mongodb://localhost:27017/mosca",
|
|
51
|
+
// MQTT订阅方式
|
|
52
|
+
"subscribe_qos": 1,
|
|
53
|
+
"protocol": "mqtt",
|
|
54
|
+
"hostname": "127.0.0.1",
|
|
55
|
+
// MQTT服务器客户端ID
|
|
56
|
+
"clientId": "server",
|
|
57
|
+
// MQTT服务器用户名
|
|
58
|
+
"username": "server",
|
|
59
|
+
// MQTT服务器密码
|
|
60
|
+
"password": "df6897hu",
|
|
61
|
+
"port": 1883
|
|
62
|
+
},
|
|
63
|
+
"mysql": {
|
|
64
|
+
// 服务器地址
|
|
65
|
+
"host": "127.0.0.1",
|
|
66
|
+
// 端口号
|
|
67
|
+
"port": 3306,
|
|
68
|
+
// 用户名
|
|
69
|
+
"user": "face",
|
|
70
|
+
// 密码
|
|
71
|
+
"password": "Asd159357",
|
|
72
|
+
// 数据库名称
|
|
73
|
+
"database": "face"
|
|
74
|
+
},
|
|
75
|
+
"redis": {
|
|
76
|
+
// 服务器地址
|
|
77
|
+
"host": "127.0.0.1",
|
|
78
|
+
// 端口号
|
|
79
|
+
"port": 6379,
|
|
80
|
+
// 密码
|
|
81
|
+
"password": "asd159357",
|
|
82
|
+
// 选用的数据库0-9
|
|
83
|
+
"database": 0,
|
|
84
|
+
// 键前缀
|
|
85
|
+
"prefix": "mm_"
|
|
86
|
+
},
|
|
87
|
+
"mongodb": {
|
|
88
|
+
// 服务器地址
|
|
89
|
+
"host": "localhost",
|
|
90
|
+
// 端口号
|
|
91
|
+
"port": 27017,
|
|
92
|
+
// 数据库名
|
|
93
|
+
"database": "face",
|
|
94
|
+
// 用户名
|
|
95
|
+
"user": "face",
|
|
96
|
+
// 密码 无则代表连接不需要账号密码
|
|
97
|
+
"password": "asd159357"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sys": {
|
|
3
|
+
// 服务端名称
|
|
4
|
+
"name": "mm",
|
|
5
|
+
// 服务端中文名
|
|
6
|
+
"title": "超级美眉",
|
|
7
|
+
// 缓存方式 memory redis mongodb
|
|
8
|
+
"cache": "redis",
|
|
9
|
+
// 系统使用的语言
|
|
10
|
+
"lang": "zh_CN",
|
|
11
|
+
// 定时任务
|
|
12
|
+
"task": false,
|
|
13
|
+
// 热重载
|
|
14
|
+
"hot_reload": true
|
|
15
|
+
},
|
|
16
|
+
"web": {
|
|
17
|
+
"state": true,
|
|
18
|
+
// 访问地址
|
|
19
|
+
"host": "0.0.0.0",
|
|
20
|
+
// 访问端口号
|
|
21
|
+
"port": 8000,
|
|
22
|
+
// 是否启用websocket
|
|
23
|
+
"socket": true,
|
|
24
|
+
// 是否启用压缩
|
|
25
|
+
"compress": false,
|
|
26
|
+
// 是否启用事件
|
|
27
|
+
"event": true,
|
|
28
|
+
// 是否启用日志
|
|
29
|
+
"log": true,
|
|
30
|
+
// 是否启用静态文件
|
|
31
|
+
"static": true,
|
|
32
|
+
// 静态文件路径
|
|
33
|
+
"static_path": "./static",
|
|
34
|
+
// 静态文件缓存时长
|
|
35
|
+
"max_age": 120000,
|
|
36
|
+
// 代理转发
|
|
37
|
+
"proxy": {}
|
|
38
|
+
},
|
|
39
|
+
"mqtt": {
|
|
40
|
+
// 是否启用MQTT
|
|
41
|
+
"state": true,
|
|
42
|
+
// mqtt访问端口号
|
|
43
|
+
"socket_port": 1883,
|
|
44
|
+
// websocket 访问端口
|
|
45
|
+
"http_port": 8083,
|
|
46
|
+
// 缓存方式
|
|
47
|
+
"cache": "memory",
|
|
48
|
+
// 缓存服务器地址
|
|
49
|
+
"cache_host": "mongodb://localhost:27017/mosca",
|
|
50
|
+
// MQTT订阅方式
|
|
51
|
+
"subscribe_qos": 0,
|
|
52
|
+
// 协议头
|
|
53
|
+
"protocol": "mqtt",
|
|
54
|
+
// MQTT服务器地址
|
|
55
|
+
"hostname": "mqtt.aieliantong.com",
|
|
56
|
+
// MQTT服务器用户名
|
|
57
|
+
"username": "developer",
|
|
58
|
+
// MQTT服务器密码
|
|
59
|
+
"password": "asd123",
|
|
60
|
+
// MQTT端口号
|
|
61
|
+
"port": 1883
|
|
62
|
+
},
|
|
63
|
+
"mysql": {
|
|
64
|
+
// 服务器地址
|
|
65
|
+
"host": "127.0.0.1",
|
|
66
|
+
// 端口号
|
|
67
|
+
"port": 3306,
|
|
68
|
+
// 用户名
|
|
69
|
+
"user": "root",
|
|
70
|
+
// 密码
|
|
71
|
+
"password": "Asd159357",
|
|
72
|
+
// 数据库名称
|
|
73
|
+
"database": "face"
|
|
74
|
+
},
|
|
75
|
+
"redis": {
|
|
76
|
+
// 服务器地址
|
|
77
|
+
"host": "127.0.0.1",
|
|
78
|
+
// 端口号
|
|
79
|
+
"port": 6379,
|
|
80
|
+
// 密码
|
|
81
|
+
"password": "asd159357",
|
|
82
|
+
// 选用的数据库0-9
|
|
83
|
+
"database": 0,
|
|
84
|
+
// 键前缀
|
|
85
|
+
"prefix": "mm_"
|
|
86
|
+
},
|
|
87
|
+
"mongodb": {
|
|
88
|
+
// 服务器地址
|
|
89
|
+
"host": "localhost",
|
|
90
|
+
// 端口号
|
|
91
|
+
"port": 27017,
|
|
92
|
+
// 数据库名
|
|
93
|
+
"database": "mqtt",
|
|
94
|
+
// 用户名
|
|
95
|
+
"user": "mqtt",
|
|
96
|
+
// 密码 无则代表连接不需要账号密码
|
|
97
|
+
"password": "asd123"
|
|
98
|
+
}
|
|
99
|
+
}
|
package/demo/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require('mm_expand');
|
|
2
|
+
const OS = require("../index.js");
|
|
3
|
+
|
|
4
|
+
$.runPath = __dirname + $.slash;
|
|
5
|
+
var NODE_ENV = process.env.NODE_ENV || 'local';
|
|
6
|
+
var config = `./config/${NODE_ENV}.json`.fullname().loadJson();
|
|
7
|
+
console.log("模式", NODE_ENV);
|
|
8
|
+
var os = new OS(config);
|
|
9
|
+
|
|
10
|
+
$.sql = $.mysql_admin('sys', __dirname);
|
|
11
|
+
$.sql.setConfig(config.mysql);
|
|
12
|
+
$.sql.open();
|
|
13
|
+
|
|
14
|
+
os.run();
|
package/index.js
CHANGED
|
@@ -14,14 +14,14 @@ var MQTT = require("./core/base/mqtt/index.js");
|
|
|
14
14
|
/**
|
|
15
15
|
* 服务端系统
|
|
16
16
|
*/
|
|
17
|
-
class
|
|
17
|
+
class OS {
|
|
18
18
|
/**
|
|
19
19
|
* 构造函数
|
|
20
20
|
* @param {Object} config 配置参数
|
|
21
21
|
*/
|
|
22
22
|
constructor(config) {
|
|
23
23
|
this.config = {
|
|
24
|
-
"runPath":
|
|
24
|
+
"runPath": "",
|
|
25
25
|
"sys": {
|
|
26
26
|
"name": "mm",
|
|
27
27
|
"title": "超级美眉",
|
|
@@ -29,6 +29,7 @@ class Soa {
|
|
|
29
29
|
"lang": "zh_CN",
|
|
30
30
|
"game": false,
|
|
31
31
|
"task": false,
|
|
32
|
+
"hot_reload": true,
|
|
32
33
|
"log": false
|
|
33
34
|
},
|
|
34
35
|
"web": {
|
|
@@ -84,14 +85,17 @@ class Soa {
|
|
|
84
85
|
* 初始化数据
|
|
85
86
|
* @param {Object} config 配置参数
|
|
86
87
|
*/
|
|
87
|
-
|
|
88
|
+
OS.prototype.initData = function(config) {
|
|
88
89
|
var p = config.runPath;
|
|
89
|
-
if
|
|
90
|
+
if(!p) {
|
|
91
|
+
config.runPath = $.runPath
|
|
92
|
+
}
|
|
93
|
+
else if (p.substring(p.length - 1) !== $.slash) {
|
|
90
94
|
config.runPath += $.slash;
|
|
91
95
|
}
|
|
92
|
-
|
|
96
|
+
|
|
93
97
|
$.runPath = config.runPath;
|
|
94
|
-
|
|
98
|
+
|
|
95
99
|
// 修改默认模板路径,改为static下,方便读取css和js
|
|
96
100
|
$.Tpl.prototype.init_main = function(cg) {
|
|
97
101
|
if (cg) {
|
|
@@ -120,7 +124,7 @@ Soa.prototype.initData = function(config) {
|
|
|
120
124
|
* 加载核心模块
|
|
121
125
|
* @param {Object} config 配置参数
|
|
122
126
|
*/
|
|
123
|
-
|
|
127
|
+
OS.prototype.loadModule = function(config) {
|
|
124
128
|
$.com = new Com();
|
|
125
129
|
$.app = new App();
|
|
126
130
|
this.com = $.com;
|
|
@@ -139,10 +143,13 @@ Soa.prototype.loadModule = function(config) {
|
|
|
139
143
|
* 初始化
|
|
140
144
|
* @param {Object} config - 配置参数
|
|
141
145
|
*/
|
|
142
|
-
|
|
146
|
+
OS.prototype.init = function(config) {
|
|
143
147
|
this.config = Object.assign(this.config, config);
|
|
144
148
|
this.initData(this.config);
|
|
145
149
|
this.loadModule(this.config);
|
|
150
|
+
if (!this.config.sys.hot_reload) {
|
|
151
|
+
$.mod.config.watch = false;
|
|
152
|
+
}
|
|
146
153
|
this.initBase(this.config);
|
|
147
154
|
}
|
|
148
155
|
|
|
@@ -150,7 +157,7 @@ Soa.prototype.init = function(config) {
|
|
|
150
157
|
* 运行基础数据
|
|
151
158
|
* @param {Object} cg - 配置对象
|
|
152
159
|
*/
|
|
153
|
-
|
|
160
|
+
OS.prototype.initBase = function(cg) {
|
|
154
161
|
var middleware = $.middleware;
|
|
155
162
|
middleware.init();
|
|
156
163
|
var mqtt, web;
|
|
@@ -213,7 +220,7 @@ Soa.prototype.initBase = function(cg) {
|
|
|
213
220
|
* 运行主程序
|
|
214
221
|
* @param {String} state 状态
|
|
215
222
|
*/
|
|
216
|
-
|
|
223
|
+
OS.prototype.main = async function(state) {
|
|
217
224
|
var cg = this.config;
|
|
218
225
|
var web_server = this.web_server;
|
|
219
226
|
var mqtt_server = this.mqtt_server;
|
|
@@ -243,7 +250,7 @@ Soa.prototype.main = async function(state) {
|
|
|
243
250
|
* 运行主程序前
|
|
244
251
|
* @param {String} state 状态
|
|
245
252
|
*/
|
|
246
|
-
|
|
253
|
+
OS.prototype.before = async function(state) {
|
|
247
254
|
await this.app.initApp();
|
|
248
255
|
};
|
|
249
256
|
|
|
@@ -251,7 +258,7 @@ Soa.prototype.before = async function(state) {
|
|
|
251
258
|
* 运行主程序后
|
|
252
259
|
* @param {String} state 状态
|
|
253
260
|
*/
|
|
254
|
-
|
|
261
|
+
OS.prototype.after = async function(state) {
|
|
255
262
|
this.app.runApp();
|
|
256
263
|
};
|
|
257
264
|
|
|
@@ -259,10 +266,10 @@ Soa.prototype.after = async function(state) {
|
|
|
259
266
|
* 运行
|
|
260
267
|
* @param {String} state 状态
|
|
261
268
|
*/
|
|
262
|
-
|
|
269
|
+
OS.prototype.run = async function(state = 'start') {
|
|
263
270
|
await this.before(state);
|
|
264
271
|
await this.main(state);
|
|
265
272
|
await this.after(state);
|
|
266
273
|
};
|
|
267
274
|
|
|
268
|
-
module.exports =
|
|
275
|
+
module.exports = OS;
|
package/lib/app.js
CHANGED
|
@@ -6,11 +6,9 @@ const Base = require("./base.js");
|
|
|
6
6
|
class App extends Base {
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
|
-
this.path = "
|
|
9
|
+
this.path = "./app".fullname();
|
|
10
10
|
// 文件拓展名
|
|
11
11
|
this.extension = "app.json";
|
|
12
|
-
// 文件存放目录
|
|
13
|
-
this.dir = "/app";
|
|
14
12
|
// 重新加载
|
|
15
13
|
this.reload = false;
|
|
16
14
|
this.init();
|
package/lib/base.js
CHANGED
|
@@ -36,8 +36,6 @@ class Base {
|
|
|
36
36
|
this.path = "";
|
|
37
37
|
// 文件拓展名
|
|
38
38
|
this.extension = "*.json";
|
|
39
|
-
// 检索路径
|
|
40
|
-
this.dir = "/data";
|
|
41
39
|
// 重新加载
|
|
42
40
|
this.reload = true;
|
|
43
41
|
// 识别用的主键
|
|
@@ -113,8 +111,8 @@ Base.prototype.load = function(jsonFile, reload = false) {
|
|
|
113
111
|
var jsFile;
|
|
114
112
|
// 加载脚本
|
|
115
113
|
if (m.script) {
|
|
116
|
-
if (m.script.indexOf(
|
|
117
|
-
jsFile =
|
|
114
|
+
if (m.script.indexOf("/") === 0) {
|
|
115
|
+
jsFile = m.script.fullname($.runPath);
|
|
118
116
|
} else {
|
|
119
117
|
jsFile = m.script.fullname(jsonFile.dirname());
|
|
120
118
|
}
|
package/lib/com.js
CHANGED
|
@@ -6,11 +6,9 @@ const Base = require("./base.js");
|
|
|
6
6
|
class Com extends Base {
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
|
-
this.path = "
|
|
9
|
+
this.path = "./com".fullname();
|
|
10
10
|
// 文件拓展名
|
|
11
11
|
this.extension = "com.json";
|
|
12
|
-
// 文件存放目录
|
|
13
|
-
this.dir = "/com";
|
|
14
12
|
// 重新加载
|
|
15
13
|
this.reload = false;
|
|
16
14
|
this.init();
|
package/lib/game.js
CHANGED
|
@@ -6,11 +6,9 @@ const Base = require("./base.js");
|
|
|
6
6
|
class Game extends Base {
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
9
|
-
this.path = "
|
|
9
|
+
this.path = "./game".fullname();
|
|
10
10
|
// 文件拓展名
|
|
11
11
|
this.extension = "game.json";
|
|
12
|
-
// 文件存放目录
|
|
13
|
-
this.dir = "/game";
|
|
14
12
|
// 重新加载
|
|
15
13
|
this.reload = false;
|
|
16
14
|
this.init();
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_os",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "这是超级美眉服务端框架,用于快速构建应用程序。",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "node ./
|
|
7
|
+
"test": "cross-env NODE_ENV=test node ./demo/index.js",
|
|
8
8
|
"start": "node ./demo/index.js",
|
|
9
9
|
"dev": "cross-env NODE_ENV=development nodemon ./demo/index.js"
|
|
10
10
|
},
|
|
@@ -35,22 +35,22 @@
|
|
|
35
35
|
"koa-compress": "^5.1.1",
|
|
36
36
|
"koa-send": "^5.0.1",
|
|
37
37
|
"koa-websocket": "^7.0.0",
|
|
38
|
-
"mm_check": "^1.4.
|
|
39
|
-
"mm_excel": "^1.1.
|
|
38
|
+
"mm_check": "^1.4.7",
|
|
39
|
+
"mm_excel": "^1.1.9",
|
|
40
40
|
"mm_expand": "^1.7.0",
|
|
41
|
-
"mm_html": "^1.1.
|
|
41
|
+
"mm_html": "^1.1.6",
|
|
42
42
|
"mm_koa_proxy": "^1.0.0",
|
|
43
|
-
"mm_logs": "^1.1.
|
|
44
|
-
"mm_machine": "^1.6.
|
|
45
|
-
"mm_mongodb": "^1.4.
|
|
46
|
-
"mm_mqtt": "^1.0.
|
|
47
|
-
"mm_mysql": "^1.
|
|
48
|
-
"mm_redis": "^1.4.
|
|
49
|
-
"mm_ret": "^1.3.
|
|
50
|
-
"mm_session": "^1.4.
|
|
51
|
-
"mm_statics": "^1.4.
|
|
52
|
-
"mm_tpl": "^2.3.
|
|
53
|
-
"mm_xml": "^1.1.
|
|
43
|
+
"mm_logs": "^1.1.4",
|
|
44
|
+
"mm_machine": "^1.6.5",
|
|
45
|
+
"mm_mongodb": "^1.4.2",
|
|
46
|
+
"mm_mqtt": "^1.0.6",
|
|
47
|
+
"mm_mysql": "^1.8.0",
|
|
48
|
+
"mm_redis": "^1.4.1",
|
|
49
|
+
"mm_ret": "^1.3.9",
|
|
50
|
+
"mm_session": "^1.4.6",
|
|
51
|
+
"mm_statics": "^1.4.2",
|
|
52
|
+
"mm_tpl": "^2.3.9",
|
|
53
|
+
"mm_xml": "^1.1.5",
|
|
54
54
|
"mosca": "^2.8.3",
|
|
55
55
|
"mqtt": "^5.10.1"
|
|
56
56
|
}
|