mm_os 4.3.7 → 5.0.1
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/README.md +102 -504
- package/index.js +26 -19
- package/lib/os.js +536 -0
- package/package.json +60 -84
- package/LICENSE +0 -21
- package/README_EN.md +0 -505
- package/adapter/adapter.js +0 -484
- package/adapter/custom_persistence.js +0 -661
- package/adapter/mqtt.js +0 -254
- package/adapter/socket.js +0 -244
- package/adapter/web.js +0 -92
- package/adapter/websocket.js +0 -43
- package/ai.js +0 -130
- package/com/api/README.md +0 -3
- package/com/api/com.json +0 -5
- package/com/api/config.tpl.json +0 -41
- package/com/api/drive.js +0 -732
- package/com/api/index.js +0 -201
- package/com/api/oauth.js +0 -200
- package/com/api/script.tpl.js +0 -32
- package/com/cmd/README.md +0 -11
- package/com/cmd/com.json +0 -5
- package/com/cmd/config.tpl.json +0 -48
- package/com/cmd/drive.js +0 -176
- package/com/cmd/index.js +0 -287
- package/com/cmd/job/config.json +0 -66
- package/com/cmd/job/index.js +0 -241
- package/com/cmd/job/test.js +0 -188
- package/com/cmd/msg.json +0 -48
- package/com/cmd/script.tpl.js +0 -12
- package/com/db/README.md +0 -3
- package/com/db/com.json +0 -5
- package/com/db/drive.js +0 -2206
- package/com/db/index.js +0 -241
- package/com/event/README.md +0 -4
- package/com/event/com.json +0 -5
- package/com/event/config.tpl.json +0 -20
- package/com/event/drive.js +0 -61
- package/com/event/index.js +0 -438
- package/com/event/script.tpl.js +0 -23
- package/com/mqtt/README.md +0 -47
- package/com/mqtt/com.json +0 -5
- package/com/mqtt/config.tpl.json +0 -42
- package/com/mqtt/drive.js +0 -704
- package/com/mqtt/index.js +0 -1052
- package/com/mqtt/index.test.js +0 -503
- package/com/mqtt/script.tpl.js +0 -719
- package/com/nav/README.md +0 -2
- package/com/nav/com.json +0 -5
- package/com/nav/config.tpl.json +0 -84
- package/com/nav/drive.js +0 -702
- package/com/nav/index.js +0 -228
- package/com/nav/tpl/admin_pc/page_channel.vue +0 -305
- package/com/nav/tpl/admin_pc/page_config.vue +0 -280
- package/com/nav/tpl/admin_pc/page_config_form.vue +0 -194
- package/com/nav/tpl/admin_pc/page_default.vue +0 -247
- package/com/nav/tpl/admin_pc/page_form.vue +0 -180
- package/com/nav/tpl/admin_pc/page_lang.vue +0 -264
- package/com/nav/tpl/admin_pc/page_nav.vue +0 -321
- package/com/nav/tpl/admin_pc/page_table.vue +0 -296
- package/com/nav/tpl/admin_pc/page_type.vue +0 -321
- package/com/nav/tpl/admin_pc/page_view.vue +0 -124
- package/com/nav/tpl/dev_pc/page_channel.vue +0 -253
- package/com/nav/tpl/dev_pc/page_config.vue +0 -253
- package/com/nav/tpl/dev_pc/page_default.vue +0 -247
- package/com/nav/tpl/dev_pc/page_form.vue +0 -162
- package/com/nav/tpl/dev_pc/page_nav.vue +0 -253
- package/com/nav/tpl/dev_pc/page_table.vue +0 -247
- package/com/nav/tpl/dev_pc/page_type.vue +0 -313
- package/com/nav/tpl/home_pc/page_channel.vue +0 -234
- package/com/nav/tpl/home_pc/page_default.vue +0 -234
- package/com/nav/tpl/home_pc/page_form.vue +0 -137
- package/com/nav/tpl/home_pc/page_list.vue +0 -234
- package/com/nav/tpl/home_pc/page_nav.vue +0 -221
- package/com/nav/tpl/home_pc/page_type.vue +0 -234
- package/com/nav/tpl/home_pc/page_view.vue +0 -125
- package/com/nav/tpl/home_phone/page_channel.vue +0 -234
- package/com/nav/tpl/home_phone/page_default.vue +0 -234
- package/com/nav/tpl/home_phone/page_form.vue +0 -137
- package/com/nav/tpl/home_phone/page_list.vue +0 -234
- package/com/nav/tpl/home_phone/page_nav.vue +0 -237
- package/com/nav/tpl/home_phone/page_type.vue +0 -234
- package/com/nav/tpl/home_phone/page_view.vue +0 -125
- package/com/nav/viewmodel.js +0 -446
- package/com/param/README.md +0 -2
- package/com/param/com.json +0 -5
- package/com/param/config.tpl.json +0 -136
- package/com/param/drive.js +0 -502
- package/com/param/index.js +0 -158
- package/com/param/script.tpl.js +0 -12
- package/com/pendant/README.md +0 -3
- package/com/pendant/com.json +0 -5
- package/com/pendant/config.tpl.json +0 -32
- package/com/pendant/drive.js +0 -204
- package/com/pendant/index.js +0 -467
- package/com/pendant/pendant.html +0 -16
- package/com/pendant/script.tpl.js +0 -18
- package/com/socket/README.md +0 -47
- package/com/socket/com.json +0 -5
- package/com/socket/config.tpl.json +0 -12
- package/com/socket/drive.js +0 -679
- package/com/socket/index.js +0 -402
- package/com/socket/script.tpl.js +0 -41
- package/com/sql/README.md +0 -3
- package/com/sql/com.json +0 -5
- package/com/sql/config.tpl.json +0 -74
- package/com/sql/drive.js +0 -1328
- package/com/sql/index.js +0 -152
- package/com/sql/script.tpl.js +0 -47
- package/com/static/README.md +0 -2
- package/com/static/com.json +0 -5
- package/com/static/config.tpl.json +0 -24
- package/com/static/drive.js +0 -194
- package/com/static/index.js +0 -237
- package/com/static/script.tpl.js +0 -28
- package/com/task/README.md +0 -3
- package/com/task/com.json +0 -5
- package/com/task/config.tpl.json +0 -24
- package/com/task/drive.js +0 -428
- package/com/task/index.js +0 -159
- package/com/task/script.tpl.js +0 -40
- package/com/template/com.json +0 -5
- package/com/template/config.tpl.json +0 -16
- package/com/template/drive.js +0 -81
- package/com/template/index.js +0 -141
- package/com.js +0 -237
- package/common/README.md +0 -2
- package/common/middleware/web_after/index.js +0 -26
- package/common/middleware/web_after/middleware.json +0 -9
- package/common/middleware/web_base/index.js +0 -113
- package/common/middleware/web_base/middleware.json +0 -19
- package/common/middleware/web_before/index.js +0 -33
- package/common/middleware/web_before/middleware.json +0 -9
- package/common/middleware/web_cors/index.js +0 -87
- package/common/middleware/web_cors/middleware.json +0 -24
- package/common/middleware/web_error/index.js +0 -131
- package/common/middleware/web_error/middleware.json +0 -19
- package/common/middleware/web_ip/index.js +0 -15
- package/common/middleware/web_ip/middleware.json +0 -14
- package/common/middleware/web_logger/index.js +0 -156
- package/common/middleware/web_logger/middleware.json +0 -14
- package/common/middleware/web_main/index.js +0 -26
- package/common/middleware/web_main/middleware.json +0 -9
- package/common/middleware/web_static/index.js +0 -73
- package/common/middleware/web_static/middleware.json +0 -54
- package/common/middleware/web_waf/index.js +0 -395
- package/common/middleware/web_waf/middleware.json +0 -13
- package/core/app/config.tpl.json +0 -67
- package/core/app/index.js +0 -711
- package/core/app/script.tpl.js +0 -52
- package/core/channel/index.js +0 -899
- package/core/channel/matcher.js +0 -585
- package/core/com/config.tpl.json +0 -16
- package/core/com/index.js +0 -77
- package/core/com/script.tpl.js +0 -5
- package/core/component/component.js +0 -42
- package/core/component/config.tpl.json +0 -63
- package/core/component/index.js +0 -273
- package/core/component/script.tpl.js +0 -19
- package/core/controller/config.tpl.json +0 -14
- package/core/controller/index.js +0 -371
- package/core/controller/script.tpl.js +0 -27
- package/core/factory/config.tpl.json +0 -14
- package/core/factory/entity.js +0 -275
- package/core/factory/index.js +0 -241
- package/core/factory/script.tpl.js +0 -16
- package/core/game/bat/index.js +0 -137
- package/core/game/bat/world.js +0 -622
- package/core/game/config.tpl.json +0 -16
- package/core/game/entity_admin.js +0 -230
- package/core/game/index.js +0 -186
- package/core/handler/config.tpl.json +0 -22
- package/core/handler/index.js +0 -181
- package/core/handler/script.tpl.js +0 -23
- package/core/logic/config.tpl.json +0 -14
- package/core/logic/index.js +0 -59
- package/core/logic/script.tpl.js +0 -19
- package/core/middleware/config.tpl.json +0 -16
- package/core/middleware/index.js +0 -117
- package/core/middleware/script.tpl.js +0 -37
- package/core/mod/config.tpl.json +0 -22
- package/core/mod/index.js +0 -136
- package/core/mod/script.tpl.js +0 -34
- package/core/model/config.tpl.json +0 -219
- package/core/model/index.js +0 -272
- package/core/model/model.js +0 -27
- package/core/model/script.tpl.js +0 -20
- package/core/notifier/config.tpl.json +0 -14
- package/core/notifier/index.js +0 -77
- package/core/notifier/script.tpl.js +0 -20
- package/core/plugin/config.tpl.json +0 -36
- package/core/plugin/index.js +0 -267
- package/core/plugin/script.tpl.js +0 -51
- package/core/pusher/config.tpl.json +0 -14
- package/core/pusher/index.js +0 -158
- package/core/pusher/script.tpl.js +0 -20
- package/core/room/bat/index.js +0 -170
- package/core/room/bat/room.js +0 -524
- package/core/room/config.tpl.json +0 -20
- package/core/room/index.js +0 -249
- package/core/room/room.js +0 -61
- package/core/scene/config.tpl.json +0 -14
- package/core/scene/index.js +0 -467
- package/core/scene/loop.js +0 -1306
- package/core/scene/map.js +0 -28
- package/core/scene/script.tpl.js +0 -22
- package/core/sender/config.tpl.json +0 -14
- package/core/sender/index.js +0 -79
- package/core/sender/script.tpl.js +0 -20
- package/core/service/config.tpl.json +0 -14
- package/core/service/index.js +0 -100
- package/core/service/script.tpl.js +0 -25
- package/core/store/config.tpl.json +0 -26
- package/core/store/index.js +0 -1794
- package/core/store/script.tpl.js +0 -22
- package/core/system/config.tpl.json +0 -18
- package/core/system/index.js +0 -312
- package/core/system/script.tpl.js +0 -77
- package/core/view/config.tpl.json +0 -14
- package/core/view/index.js +0 -91
- package/core/view/script.tpl.js +0 -20
- package/core/zone/bat/index.js +0 -744
- package/core/zone/config.tpl.json +0 -54
- package/core/zone/index.js +0 -655
- package/core/zone/script.tpl.js +0 -10
- package/core/zone/zone_bat.js +0 -136
- package/core//345/237/272/347/261/273/346/250/241/345/235/227/346/270/205/345/215/225.md +0 -24
- package/os.js +0 -53
- package/server.js +0 -602
- package/ulits/id_gen.js +0 -134
- package/ulits/word.js +0 -206
package/core/logic/script.tpl.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 游戏逻辑
|
|
3
|
-
*/
|
|
4
|
-
module.exports = {
|
|
5
|
-
/**
|
|
6
|
-
* 初始化
|
|
7
|
-
*/
|
|
8
|
-
async _init() {
|
|
9
|
-
// this.log('debug', '初始化');
|
|
10
|
-
},
|
|
11
|
-
/**
|
|
12
|
-
* 主要逻辑
|
|
13
|
-
* @param {...any} args 参数列表
|
|
14
|
-
*/
|
|
15
|
-
async main(...args) {
|
|
16
|
-
this.log('debug', 'logic main 被调用', { args });
|
|
17
|
-
// 主要代码写在这
|
|
18
|
-
}
|
|
19
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// 名称
|
|
3
|
-
"name": "${name}",
|
|
4
|
-
// 标题
|
|
5
|
-
"title": "${title || '示例中间件'}",
|
|
6
|
-
// 描述
|
|
7
|
-
"description": "${description || '用于中间件演示'}",
|
|
8
|
-
// 主文件
|
|
9
|
-
"main": "${main || 'index.js'}",
|
|
10
|
-
// 类型
|
|
11
|
-
"type": "${type || 'web'}",
|
|
12
|
-
// 排序,越小越靠前
|
|
13
|
-
"sort": 100,
|
|
14
|
-
// 状态 0:禁用 1:启用
|
|
15
|
-
"state": 1
|
|
16
|
-
}
|
package/core/middleware/index.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
Drive
|
|
3
|
-
} = require('mm_machine');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Koa中间件基类
|
|
7
|
-
*/
|
|
8
|
-
class Middleware extends Drive {
|
|
9
|
-
static config = {
|
|
10
|
-
// 中间件名称
|
|
11
|
-
name: 'default',
|
|
12
|
-
// 状态 0:禁用 1:启用
|
|
13
|
-
state: 1,
|
|
14
|
-
// 排序,越小越靠前
|
|
15
|
-
sort: 100
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* 构造函数
|
|
19
|
-
* @param {object} config 配置参数
|
|
20
|
-
* @param {object} parent 父对象
|
|
21
|
-
*/
|
|
22
|
-
constructor(config, parent) {
|
|
23
|
-
super({ ...Middleware.config, ...config || {} }, parent);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* 获取模板目录
|
|
29
|
-
* @returns {string} 模板目录
|
|
30
|
-
*/
|
|
31
|
-
Middleware.prototype.getTplDir = function () {
|
|
32
|
-
return __dirname;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* 初始化核心
|
|
37
|
-
* @param {object} adapter 适配器
|
|
38
|
-
* @param {object} eventer 事件总线
|
|
39
|
-
* @param {object} logger 日志管理器
|
|
40
|
-
* @returns {Promise<void>}
|
|
41
|
-
*/
|
|
42
|
-
Middleware.prototype._initCore = async function (adapter, eventer, logger) {
|
|
43
|
-
// 初始化依赖项
|
|
44
|
-
if (logger) {
|
|
45
|
-
this.setLogger(logger);
|
|
46
|
-
}
|
|
47
|
-
if (eventer) {
|
|
48
|
-
this.getEventer = function () {
|
|
49
|
-
return eventer;
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
if (adapter) {
|
|
53
|
-
this.getAdapter = function () {
|
|
54
|
-
return adapter[this.config.type];
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
this._register();
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* 注册中间件
|
|
62
|
-
* @private
|
|
63
|
-
* @returns {Promise<void>}
|
|
64
|
-
*/
|
|
65
|
-
Middleware.prototype._register = async function () {
|
|
66
|
-
// 注册中间件到Koa应用
|
|
67
|
-
this.getAdapter().web.use(this.create());
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 创建中间件函数
|
|
72
|
-
* @returns {Function} Koa中间件函数
|
|
73
|
-
*/
|
|
74
|
-
Middleware.prototype.create = function () {
|
|
75
|
-
var self = this;
|
|
76
|
-
if (!this.config.state) {
|
|
77
|
-
return async function (ctx, next) {
|
|
78
|
-
return await next();
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
return async (ctx, next) => {
|
|
82
|
-
await self.before(ctx);
|
|
83
|
-
await self.main(ctx, next);
|
|
84
|
-
await self.after(ctx);
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 中间件前置处理
|
|
90
|
-
* @returns {Promise<void>}
|
|
91
|
-
*/
|
|
92
|
-
Middleware.prototype.before = async function () {
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* 中间件主逻辑处理
|
|
97
|
-
* @param {object} ctx Koa上下文
|
|
98
|
-
* @param {Function} next 下一个中间件
|
|
99
|
-
* @returns {Promise<void>}
|
|
100
|
-
*/
|
|
101
|
-
Middleware.prototype.main = async function (ctx, next) {
|
|
102
|
-
await next();
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* 中间件后置处理
|
|
107
|
-
* @returns {Promise<void>}
|
|
108
|
-
*/
|
|
109
|
-
Middleware.prototype.after = async function () {
|
|
110
|
-
// 默认空实现,由子类重写
|
|
111
|
-
// this.log('debug', 'middleware after 被调用', { ctx });
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// 模块导出
|
|
115
|
-
module.exports = {
|
|
116
|
-
Middleware
|
|
117
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 中间件
|
|
3
|
-
*/
|
|
4
|
-
module.exports = {
|
|
5
|
-
/**
|
|
6
|
-
* 中间件初始化
|
|
7
|
-
* @param {object} adapter 适配器
|
|
8
|
-
* @param {object} eventer 事件处理器
|
|
9
|
-
*/
|
|
10
|
-
async _init(adapter, eventer) {
|
|
11
|
-
this.log('debug', 'middleware _init 被调用', { adapter, eventer });
|
|
12
|
-
// 初始化代码写在这
|
|
13
|
-
// 可在这里注入其他中间件
|
|
14
|
-
},
|
|
15
|
-
/**
|
|
16
|
-
* 中间件执行前,可用于触发事件
|
|
17
|
-
*/
|
|
18
|
-
async before() {
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
/**
|
|
22
|
-
* 中间件执行后,可用于触发事件
|
|
23
|
-
*/
|
|
24
|
-
async after() {
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
/**
|
|
28
|
-
* 主要逻辑
|
|
29
|
-
* @param {object} ctx Koa上下文
|
|
30
|
-
* @param {Function} next 下一个中间件
|
|
31
|
-
*/
|
|
32
|
-
async main(ctx, next) {
|
|
33
|
-
this.log('debug', 'middleware main 被调用', { ctx });
|
|
34
|
-
// 主要代码写在这
|
|
35
|
-
await next();
|
|
36
|
-
}
|
|
37
|
-
};
|
package/core/mod/config.tpl.json
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// 名称
|
|
3
|
-
"name": "${name}",
|
|
4
|
-
// 标题
|
|
5
|
-
"title": "${title || '示例模块'}",
|
|
6
|
-
// 描述
|
|
7
|
-
"description": "${description || '介绍该模块有什么用'}",
|
|
8
|
-
// 版本号
|
|
9
|
-
"version": "${version || '1.0.0'}",
|
|
10
|
-
// 作者
|
|
11
|
-
"author": "${author || 'qww'}",
|
|
12
|
-
// 作用域,决定加载到什么区域
|
|
13
|
-
"scope": "${scope || 'server'}",
|
|
14
|
-
// 主文件
|
|
15
|
-
"main": "${main || 'index.js'}",
|
|
16
|
-
// 状态 0:禁用 1:启用
|
|
17
|
-
"state": 1,
|
|
18
|
-
// 排序,越小越靠前
|
|
19
|
-
"sort": 100,
|
|
20
|
-
// 依赖的npm module
|
|
21
|
-
"dependencies": []
|
|
22
|
-
}
|
package/core/mod/index.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
Drive
|
|
3
|
-
} = require('mm_machine');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 模组基类
|
|
7
|
-
* 扩展插件功能,用于管理和协调多个应用和插件
|
|
8
|
-
*/
|
|
9
|
-
class Mod extends Drive {
|
|
10
|
-
static config = {
|
|
11
|
-
// 模组名称
|
|
12
|
-
name: 'default',
|
|
13
|
-
// 模组版本
|
|
14
|
-
version: '1.0.0',
|
|
15
|
-
// 依赖的npm模块
|
|
16
|
-
dependencies: [],
|
|
17
|
-
// 作者
|
|
18
|
-
author: 'qww',
|
|
19
|
-
// 模组目录
|
|
20
|
-
dir: './mod'
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* 构造函数
|
|
24
|
-
* @param {object} config 配置参数
|
|
25
|
-
* @param {object} parent 父对象
|
|
26
|
-
*/
|
|
27
|
-
constructor(config, parent) {
|
|
28
|
-
super({ ...Mod.config, ...config || {} }, parent);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* 预设
|
|
34
|
-
*/
|
|
35
|
-
Mod.prototype._preset = function () {
|
|
36
|
-
// 服务器实例
|
|
37
|
-
this.getServer = function () {
|
|
38
|
-
return $.server;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* 获取模板目录
|
|
44
|
-
* @returns {string} 模板目录
|
|
45
|
-
*/
|
|
46
|
-
Mod.prototype.getTplDir = function () {
|
|
47
|
-
return __dirname;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* 初始化核心
|
|
52
|
-
* @param {object} server 服务
|
|
53
|
-
* @param {object} eventer 事件总线
|
|
54
|
-
* @param {object} logger 日志管理器
|
|
55
|
-
* @private
|
|
56
|
-
*/
|
|
57
|
-
Mod.prototype._initCore = async function (server, eventer, logger) {
|
|
58
|
-
// 初始化依赖项
|
|
59
|
-
if (logger) {
|
|
60
|
-
this.setLogger(logger);
|
|
61
|
-
}
|
|
62
|
-
if (eventer) {
|
|
63
|
-
this.getEventer = function () {
|
|
64
|
-
return eventer;
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
if (server) {
|
|
68
|
-
this.getServer = function () {
|
|
69
|
-
return server;
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// 初始化管理
|
|
75
|
-
await this._initManager();
|
|
76
|
-
// 加载资源
|
|
77
|
-
await this._loadSources();
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* 启动核心
|
|
82
|
-
*/
|
|
83
|
-
Mod.prototype._startCore = async function () {
|
|
84
|
-
// 初始化资源
|
|
85
|
-
await this._initSources();
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* 初始化管理器
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
Mod.prototype._initManager = async function () {
|
|
93
|
-
this.log('debug', 'mod _initManager 被调用');
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* 加载资源
|
|
98
|
-
* @private
|
|
99
|
-
*/
|
|
100
|
-
Mod.prototype._loadSources = async function () {
|
|
101
|
-
this.log('debug', 'mod _loadSources 被调用');
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* 初始化资源
|
|
106
|
-
* @private
|
|
107
|
-
*/
|
|
108
|
-
Mod.prototype._initSources = async function () {
|
|
109
|
-
this.log('debug', 'mod _initSources 被调用');
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* 启动模组
|
|
114
|
-
*/
|
|
115
|
-
Mod.prototype._start = async function () {
|
|
116
|
-
try {
|
|
117
|
-
this.log('info', 'started');
|
|
118
|
-
} catch (error) {
|
|
119
|
-
this.log('error', 'start error:', error);
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* 停止模组
|
|
125
|
-
*/
|
|
126
|
-
Mod.prototype._stop = async function () {
|
|
127
|
-
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* 清理模组资源
|
|
132
|
-
*/
|
|
133
|
-
Mod.prototype._cleanup = async function () {
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
exports.Mod = Mod;
|
package/core/mod/script.tpl.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 模组,用于拓展游戏玩法
|
|
3
|
-
*/
|
|
4
|
-
module.exports = {
|
|
5
|
-
/**
|
|
6
|
-
* 安装
|
|
7
|
-
*/
|
|
8
|
-
async _install() {
|
|
9
|
-
this.log('info', `应用安装`);
|
|
10
|
-
},
|
|
11
|
-
/**
|
|
12
|
-
* 卸载
|
|
13
|
-
*/
|
|
14
|
-
async _uninstall() {
|
|
15
|
-
this.log('info', `应用卸载`);
|
|
16
|
-
},
|
|
17
|
-
/**
|
|
18
|
-
* 初始化
|
|
19
|
-
* @param {object} server 服务器对象
|
|
20
|
-
* @param {object} eventer 事件处理器
|
|
21
|
-
* @returns {Promise<void>}
|
|
22
|
-
*/
|
|
23
|
-
async _init(server, eventer) {
|
|
24
|
-
// this.log('debug', `初始化!`);
|
|
25
|
-
},
|
|
26
|
-
/**
|
|
27
|
-
* 主要逻辑
|
|
28
|
-
* @param {...any} args 参数列表
|
|
29
|
-
*/
|
|
30
|
-
async main(...args) {
|
|
31
|
-
this.log('debug', `main 被调用`, { args });
|
|
32
|
-
// 主要代码写在这
|
|
33
|
-
}
|
|
34
|
-
};
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
// 名称
|
|
3
|
-
"name": "${name}",
|
|
4
|
-
// 标题
|
|
5
|
-
"title": "${title || '用户账户模型'}",
|
|
6
|
-
// 描述
|
|
7
|
-
"description": "${description || '定于用户账户模型的组件'}",
|
|
8
|
-
// 主文件
|
|
9
|
-
"main": "${main || ''}",
|
|
10
|
-
// 状态 0:禁用 1:启用
|
|
11
|
-
"state": 1,
|
|
12
|
-
// 排序,越小越靠前
|
|
13
|
-
"sort": 100,
|
|
14
|
-
// 模型包含字段
|
|
15
|
-
"fields": {
|
|
16
|
-
"user_id": {
|
|
17
|
-
// 值类型
|
|
18
|
-
"type": "number",
|
|
19
|
-
// 数据类型
|
|
20
|
-
"data_type": "int",
|
|
21
|
-
// 标题
|
|
22
|
-
"title": "用户ID",
|
|
23
|
-
// 描述
|
|
24
|
-
"description": "用户的唯一标识符",
|
|
25
|
-
// 最小值
|
|
26
|
-
"min": 1,
|
|
27
|
-
// 最大值
|
|
28
|
-
"max": 10000000,
|
|
29
|
-
// 默认值
|
|
30
|
-
"default": 0,
|
|
31
|
-
// 是否主键
|
|
32
|
-
"primary_key": true,
|
|
33
|
-
// 是否自动增长
|
|
34
|
-
"auto": true
|
|
35
|
-
},
|
|
36
|
-
"username": {
|
|
37
|
-
"type": "string",
|
|
38
|
-
"data_type": "varchar",
|
|
39
|
-
"title": "用户名",
|
|
40
|
-
"description": "用户的显示名称",
|
|
41
|
-
// 最小长度
|
|
42
|
-
"min": 1,
|
|
43
|
-
// 最大长度
|
|
44
|
-
"max": 24,
|
|
45
|
-
"default": ""
|
|
46
|
-
},
|
|
47
|
-
"password": {
|
|
48
|
-
"type": "string",
|
|
49
|
-
"data_type": "varchar",
|
|
50
|
-
"title": "密码",
|
|
51
|
-
"description": "用户的密码",
|
|
52
|
-
"min": 1,
|
|
53
|
-
"max": 32,
|
|
54
|
-
"default": ""
|
|
55
|
-
},
|
|
56
|
-
"salt": {
|
|
57
|
-
"type": "string",
|
|
58
|
-
"data_type": "varchar",
|
|
59
|
-
"title": "盐值",
|
|
60
|
-
"description": "用户密码的盐值",
|
|
61
|
-
"min": 1,
|
|
62
|
-
"max": 32,
|
|
63
|
-
"default": "mm2025"
|
|
64
|
-
},
|
|
65
|
-
"state": {
|
|
66
|
-
"type": "number",
|
|
67
|
-
"data_type": "int",
|
|
68
|
-
"title": "状态",
|
|
69
|
-
"description": "账户的状态",
|
|
70
|
-
"min": 1,
|
|
71
|
-
"max": 10000000,
|
|
72
|
-
"default": 1,
|
|
73
|
-
"enum": [
|
|
74
|
-
{
|
|
75
|
-
"value": 1,
|
|
76
|
-
"label": "可用"
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
"value": 2,
|
|
80
|
-
"label": "异常"
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
"value": 3,
|
|
84
|
-
"label": "已冻结"
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
"value": 4,
|
|
88
|
-
"label": "已注销"
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
},
|
|
92
|
-
"avatar": {
|
|
93
|
-
"type": "string",
|
|
94
|
-
"data_type": "varchar",
|
|
95
|
-
"title": "头像",
|
|
96
|
-
"description": "用户的头像",
|
|
97
|
-
"min": 1,
|
|
98
|
-
"max": 255,
|
|
99
|
-
"default": "/avatar.jpg"
|
|
100
|
-
},
|
|
101
|
-
"nickname": {
|
|
102
|
-
"type": "string",
|
|
103
|
-
"data_type": "varchar",
|
|
104
|
-
"title": "昵称",
|
|
105
|
-
"description": "用户的昵称",
|
|
106
|
-
"min": 1,
|
|
107
|
-
"max": 24,
|
|
108
|
-
"default": ""
|
|
109
|
-
},
|
|
110
|
-
"vip": {
|
|
111
|
-
"type": "number",
|
|
112
|
-
"data_type": "int",
|
|
113
|
-
"title": "会员等级",
|
|
114
|
-
"description": "用户的会员等级",
|
|
115
|
-
"min": 0,
|
|
116
|
-
"max": 10000000,
|
|
117
|
-
"default": 0
|
|
118
|
-
},
|
|
119
|
-
"gm": {
|
|
120
|
-
"type": "number",
|
|
121
|
-
"data_type": "int",
|
|
122
|
-
"title": "管理员等级",
|
|
123
|
-
"description": "用户的管理员等级",
|
|
124
|
-
"min": 0,
|
|
125
|
-
"max": 10000000,
|
|
126
|
-
"default": 0
|
|
127
|
-
},
|
|
128
|
-
"mc": {
|
|
129
|
-
"type": "number",
|
|
130
|
-
"data_type": "int",
|
|
131
|
-
"title": "商家等级",
|
|
132
|
-
"description": "用户的商家等级",
|
|
133
|
-
"min": 0,
|
|
134
|
-
"max": 10000000,
|
|
135
|
-
"default": 0
|
|
136
|
-
},
|
|
137
|
-
"email": {
|
|
138
|
-
"type": "string",
|
|
139
|
-
"data_type": "varchar",
|
|
140
|
-
"title": "邮箱",
|
|
141
|
-
"description": "用户的邮箱",
|
|
142
|
-
"min": 1,
|
|
143
|
-
"max": 255,
|
|
144
|
-
"default": ""
|
|
145
|
-
},
|
|
146
|
-
"phone": {
|
|
147
|
-
"type": "string",
|
|
148
|
-
"data_type": "varchar",
|
|
149
|
-
"title": "手机号",
|
|
150
|
-
"description": "用户的手机号",
|
|
151
|
-
"min": 1,
|
|
152
|
-
"max": 11,
|
|
153
|
-
"default": ""
|
|
154
|
-
},
|
|
155
|
-
"admin_group": {
|
|
156
|
-
"type": "string",
|
|
157
|
-
"data_type": "varchar",
|
|
158
|
-
"title": "管理员组",
|
|
159
|
-
"description": "用户所属的管理员组集合",
|
|
160
|
-
"min": 0,
|
|
161
|
-
"max": 255,
|
|
162
|
-
"default": ""
|
|
163
|
-
},
|
|
164
|
-
"user_group": {
|
|
165
|
-
"type": "string",
|
|
166
|
-
"data_type": "varchar",
|
|
167
|
-
"title": "用户组",
|
|
168
|
-
"description": "用户所属的用户组集合",
|
|
169
|
-
"min": 0,
|
|
170
|
-
"max": 255,
|
|
171
|
-
"default": "default"
|
|
172
|
-
},
|
|
173
|
-
"referee_id": {
|
|
174
|
-
"type": "number",
|
|
175
|
-
"data_type": "int",
|
|
176
|
-
"title": "推荐人ID",
|
|
177
|
-
"description": "用户的推荐人ID",
|
|
178
|
-
"min": 1,
|
|
179
|
-
"max": 10000000,
|
|
180
|
-
"default": 0
|
|
181
|
-
},
|
|
182
|
-
"login_ip": {
|
|
183
|
-
"type": "string",
|
|
184
|
-
"data_type": "varchar",
|
|
185
|
-
"title": "登录IP",
|
|
186
|
-
"description": "用户最近一次登录的IP地址",
|
|
187
|
-
"min": 0,
|
|
188
|
-
"max": 255,
|
|
189
|
-
"default": "127.0.0.1"
|
|
190
|
-
},
|
|
191
|
-
"login_time": {
|
|
192
|
-
"type": "string",
|
|
193
|
-
"data_type": "datetime",
|
|
194
|
-
"title": "登录时间",
|
|
195
|
-
"description": "用户最近一次登录的时间",
|
|
196
|
-
"min": 1,
|
|
197
|
-
"max": 20,
|
|
198
|
-
"default": "1970-01-01 00:00:00"
|
|
199
|
-
},
|
|
200
|
-
"time_create": {
|
|
201
|
-
"type": "string",
|
|
202
|
-
"data_type": "datetime",
|
|
203
|
-
"title": "创建时间",
|
|
204
|
-
"description": "用户账户的创建时间",
|
|
205
|
-
"min": 1,
|
|
206
|
-
"max": 20,
|
|
207
|
-
"default": "now()"
|
|
208
|
-
},
|
|
209
|
-
"time_update": {
|
|
210
|
-
"type": "string",
|
|
211
|
-
"data_type": "datetime",
|
|
212
|
-
"title": "更新时间",
|
|
213
|
-
"description": "用户账户的更新时间",
|
|
214
|
-
"min": 1,
|
|
215
|
-
"max": 20,
|
|
216
|
-
"default": "1970-01-01 00:00:00"
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|