mm_machine 2.2.9 → 2.3.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/drive.js +6 -6
- package/index.js +72 -15
- package/package.json +1 -1
package/drive.js
CHANGED
|
@@ -146,11 +146,11 @@ Drive.prototype._getDir = function () {
|
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
|
-
*
|
|
150
|
-
* @returns {string}
|
|
149
|
+
* 获取模板目录
|
|
150
|
+
* @returns {string} 模板目录
|
|
151
151
|
*/
|
|
152
|
-
Drive.prototype.
|
|
153
|
-
return this.getParent().
|
|
152
|
+
Drive.prototype._getTplDir = function () {
|
|
153
|
+
return this.getParent().getTplDir();
|
|
154
154
|
};
|
|
155
155
|
|
|
156
156
|
/**
|
|
@@ -173,7 +173,7 @@ Drive.prototype._createScriptFile = function (file, model = {}, tpl_dir = '') {
|
|
|
173
173
|
* @returns {string} 脚本模板内容
|
|
174
174
|
*/
|
|
175
175
|
Drive.prototype.getScriptTpl = function (tpl_dir = '') {
|
|
176
|
-
var f = './script.tpl.js'.fullname(tpl_dir || this.
|
|
176
|
+
var f = './script.tpl.js'.fullname(tpl_dir || this._getTplDir());
|
|
177
177
|
if (f.hasFile()) {
|
|
178
178
|
return f.loadText();
|
|
179
179
|
} else {
|
|
@@ -351,7 +351,7 @@ Drive.prototype._createConfigFile = function (file) {
|
|
|
351
351
|
* @returns {string} 配置模板内容
|
|
352
352
|
*/
|
|
353
353
|
Drive.prototype.getConfigTpl = function (tpl_dir = '') {
|
|
354
|
-
var f = './config.tpl.json'.fullname(tpl_dir || this.
|
|
354
|
+
var f = './config.tpl.json'.fullname(tpl_dir || this._getTplDir());
|
|
355
355
|
if (f.hasFile()) {
|
|
356
356
|
return f.loadText();
|
|
357
357
|
} else {
|
package/index.js
CHANGED
|
@@ -5,27 +5,76 @@ const { Drive } = require('./drive.js');
|
|
|
5
5
|
* 管理器类
|
|
6
6
|
*/
|
|
7
7
|
class Manager extends Mod {
|
|
8
|
+
/**
|
|
9
|
+
* 配置项
|
|
10
|
+
* @type {object}
|
|
11
|
+
*/
|
|
8
12
|
static config = {
|
|
9
|
-
|
|
13
|
+
/**
|
|
14
|
+
* 管理器名称
|
|
15
|
+
* @type {string}
|
|
16
|
+
*/
|
|
10
17
|
name: 'manager',
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
18
|
+
/**
|
|
19
|
+
* 管理器标题
|
|
20
|
+
* @type {string}
|
|
21
|
+
*/
|
|
22
|
+
title: '管理器',
|
|
23
|
+
/**
|
|
24
|
+
* 管理器描述
|
|
25
|
+
* @type {string}
|
|
26
|
+
*/
|
|
27
|
+
description: '用于管理驱动',
|
|
28
|
+
/**
|
|
29
|
+
* 检索文件名
|
|
30
|
+
* @type {string}
|
|
31
|
+
*/
|
|
32
|
+
filename: 'manager.json',
|
|
33
|
+
/**
|
|
34
|
+
* 模板目录
|
|
35
|
+
* @type {string}
|
|
36
|
+
*/
|
|
37
|
+
tpl_dir: __dirname,
|
|
38
|
+
/**
|
|
39
|
+
* 基础目录,加载模块内置资源
|
|
40
|
+
* @type {string}
|
|
41
|
+
*/
|
|
14
42
|
base_dir: '../common/manager'.fullname(__dirname),
|
|
15
|
-
|
|
43
|
+
/**
|
|
44
|
+
* 自定义目录,加载项目自定义资源
|
|
45
|
+
* @type {string}
|
|
46
|
+
*/
|
|
16
47
|
dir: './ai/manager'.fullname(),
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
48
|
+
/**
|
|
49
|
+
* 类型 script脚本 | json配置 | drive驱动
|
|
50
|
+
* @type {string}
|
|
51
|
+
*/
|
|
52
|
+
type: 'drive',
|
|
53
|
+
/**
|
|
54
|
+
* 是否懒加载
|
|
55
|
+
* @type {boolean}
|
|
56
|
+
*/
|
|
20
57
|
lazy_load: true,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
58
|
+
/**
|
|
59
|
+
* 模式
|
|
60
|
+
* 1.生产模式,改变文件不会重新加载
|
|
61
|
+
* 2.热更新模式,改变配置文件会重新加载配置,不重新加载脚本
|
|
62
|
+
* 3.热重载模式,改变配置文件都会加载配置和脚本
|
|
63
|
+
* 4.热更新+重载模式,改变配置文件重新加载配置和脚本,执行完后重新加载脚本
|
|
64
|
+
* 5.重载模式,执行完后重新加载脚本,避免变量污染
|
|
65
|
+
* @type {number}
|
|
66
|
+
*/
|
|
67
|
+
mode: 3,
|
|
68
|
+
/**
|
|
69
|
+
* 排序项
|
|
70
|
+
* @type {string}
|
|
71
|
+
*/
|
|
24
72
|
sort_key: 'sort',
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
73
|
+
/**
|
|
74
|
+
* 作用域(同时作为检索的后缀名)
|
|
75
|
+
* @type {string}
|
|
76
|
+
*/
|
|
77
|
+
scope: ($.val && $.val.scope) ? $.val.scope + '' : 'server'
|
|
29
78
|
};
|
|
30
79
|
|
|
31
80
|
/**
|
|
@@ -78,6 +127,14 @@ Manager.prototype.getBaseDir = function () {
|
|
|
78
127
|
return this.config.base_dir || __dirname;
|
|
79
128
|
};
|
|
80
129
|
|
|
130
|
+
/**
|
|
131
|
+
* 获取模板目录
|
|
132
|
+
* @returns {string} 模板目录
|
|
133
|
+
*/
|
|
134
|
+
Manager.prototype.getTplDir = function () {
|
|
135
|
+
return this.config.tpl_dir || __dirname;
|
|
136
|
+
};
|
|
137
|
+
|
|
81
138
|
/**
|
|
82
139
|
* 默认驱动
|
|
83
140
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "A flexible Node.js plugin mechanism system for dynamic loading, management and execution of modules. Supports hot reload, lifecycle management, and modern JavaScript features.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|