mm_tpl 2.2.7 → 2.2.8
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/cache/test.cache.html +1 -0
- package/hook.js +3 -3
- package/index.js +1 -1
- package/package.json +1 -1
- package/template/diy/ad.html +1 -0
- package/test.js +6 -5
package/cache/test.cache.html
CHANGED
package/hook.js
CHANGED
|
@@ -175,18 +175,18 @@ Hook.prototype.runAction = function(name, model, ...args) {
|
|
|
175
175
|
/**
|
|
176
176
|
* 运行过滤钩子
|
|
177
177
|
* @param {String} name 钩子名称
|
|
178
|
-
* @param {Object} ret 结果
|
|
179
178
|
* @param {Object} model 模型
|
|
179
|
+
* @param {Object} ret 结果
|
|
180
180
|
* @param {Object} args 附加参数
|
|
181
181
|
*/
|
|
182
|
-
Hook.prototype.runFilter = function(name,
|
|
182
|
+
Hook.prototype.runFilter = function(name, model, ret, ...args) {
|
|
183
183
|
var dict = this.dict_filter;
|
|
184
184
|
var list = dict[name];
|
|
185
185
|
if (list) {
|
|
186
186
|
for (var i = 0; i < list.length; i++) {
|
|
187
187
|
var o = list[i];
|
|
188
188
|
try {
|
|
189
|
-
ret = o.func(
|
|
189
|
+
ret = o.func(model, ret, ...args);
|
|
190
190
|
} catch (err) {
|
|
191
191
|
console.error(ret);
|
|
192
192
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
package/template/diy/ad.html
CHANGED
package/test.js
CHANGED
|
@@ -55,7 +55,7 @@ async function test() {
|
|
|
55
55
|
if (query.project_id) {
|
|
56
56
|
m.project_id = query.project_id;
|
|
57
57
|
}
|
|
58
|
-
console.log(m);
|
|
58
|
+
console.log("列表", m);
|
|
59
59
|
});
|
|
60
60
|
|
|
61
61
|
$.hook.addAction('test', function aa(m, param) {
|
|
@@ -67,13 +67,14 @@ async function test() {
|
|
|
67
67
|
return "<div>你好!</div>";
|
|
68
68
|
}, 1, "测试动作1");
|
|
69
69
|
|
|
70
|
-
$.hook.addFilter('test', function(
|
|
71
|
-
|
|
70
|
+
$.hook.addFilter('test', function(m, ret, param) {
|
|
71
|
+
console.log("测试", ret);
|
|
72
|
+
// console.log(param, ret, m);
|
|
72
73
|
return ret.replace("你", "您");
|
|
73
74
|
}, 1, "测试过滤");
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
$.hook.delAction('test', "aa");
|
|
77
|
+
$.hook.delAction('test', "测试动作1");
|
|
77
78
|
// $.hook.delFilter('test', "测试过滤");
|
|
78
79
|
|
|
79
80
|
await tpl.runFunc('list', {
|