mm_tpl 2.4.4 → 2.4.6

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/index.js CHANGED
@@ -1,6 +1,8 @@
1
- require('mm_logs');
2
1
  const template = require('art-template');
3
2
  const Hook = require('./hook.js');
3
+ const {
4
+ Base
5
+ } = require('mm_expand');
4
6
  const {
5
7
  nativeRule,
6
8
  artRule,
@@ -22,18 +24,13 @@ if (!$.hook) {
22
24
  * 模板类
23
25
  * @class
24
26
  */
25
- class Tpl {
27
+ class Tpl extends Base {
26
28
  /**
27
- * 创建模板帮助类函数 (构造函数)
28
- * @param {String} scope 作用域
29
- * @param {String} dir 文件存储路径
30
- * @constructor
29
+ * 创建模板实例
30
+ * @param {Object} config - 配置选项
31
31
  */
32
32
  constructor(config) {
33
- /**
34
- * 配置参数
35
- */
36
- this.config = {
33
+ super(Object.assign({
37
34
  root: $.runPath + '',
38
35
  default_dir: "./template/",
39
36
  default_theme: 'default',
@@ -42,7 +39,7 @@ class Tpl {
42
39
  cache_root: './cache'.fullname(),
43
40
  cache_extname: '.cache.html',
44
41
  change_str: ["\\#", "\\<", "\\${", "\\/*", '\\"""'],
45
- };
42
+ }, config));
46
43
 
47
44
  /**
48
45
  * 模板引擎
@@ -50,13 +47,10 @@ class Tpl {
50
47
  this.template = template;
51
48
 
52
49
  /**
53
- * 视图背包
50
+ * 视图数据
54
51
  */
55
52
  this.viewBag = {};
56
53
 
57
- // 修改配置
58
- this.setConfig(config);
59
-
60
54
  /**
61
55
  * 模板根目录
62
56
  */
@@ -86,10 +80,10 @@ class Tpl {
86
80
  }
87
81
 
88
82
  /**
89
- * 修改配置
90
- * @param {Object} config 配置参数
83
+ * 设置配置
84
+ * @param {Object} config - 配置参数
91
85
  */
92
- Tpl.prototype.setConfig = function(config) {
86
+ Tpl.prototype.setConfig = function (config) {
93
87
  if (config) {
94
88
  this.config = Object.assign(this.config, config);
95
89
  }
@@ -104,35 +98,44 @@ Tpl.prototype.setConfig = function(config) {
104
98
 
105
99
 
106
100
  /**
107
- * 执行函数钩子
108
- * @param {String} name 名称
109
- * @param {Object} req 请求参数
110
- * @param {Object} args 附加参数
101
+ * 执行钩子函数
102
+ * @param {string} name - 钩子名称
103
+ * @param {Object} req - 请求参数
104
+ * @param {...any} args - 附加参数
105
+ * @returns {any} 执行结果
111
106
  */
112
- Tpl.prototype.runFunc = function(name, req, ...args) {
107
+ Tpl.prototype.runFunc = function (name, req, ...args) {
113
108
  return $.hook.runFunc(name, this.viewBag, req, ...args);
114
109
  }
115
110
 
111
+ /**
112
+ * 执行钩子函数
113
+ * @param {string} name - 钩子名称
114
+ * @param {Object} req - 请求参数
115
+ * @param {...any} args - 附加参数
116
+ * @returns {any} 执行结果
117
+ */
118
+ Tpl.prototype.runHook = Tpl.prototype.runFunc;
116
119
 
117
120
  /**
118
- * 初始化之前
119
- * @param {Object} config 配置参数
121
+ * 初始化前处理
122
+ * @param {Object} config - 配置参数
120
123
  */
121
- Tpl.prototype.init_before = function(config) {}
124
+ Tpl.prototype._initBefore = function (config) { }
122
125
 
123
126
  /**
124
- * 初始化主体
125
- * @param {Object} config 配置参数
127
+ * 初始化主处理
128
+ * @param {Object} config - 配置参数
126
129
  */
127
- Tpl.prototype.init_main = function(config) {
130
+ Tpl.prototype._initMain = function (config) {
128
131
  this.setConfig(config);
129
132
  }
130
133
 
131
134
  /**
132
- * 初始化之后
133
- * @param {Object} config 配置参数
135
+ * 初始化后处理
136
+ * @param {Object} config - 配置参数
134
137
  */
135
- Tpl.prototype.init_after = function(config) {
138
+ Tpl.prototype._initAfter = function (config) {
136
139
  var lt = this.config.change_str;
137
140
  for (var i = 0; i < lt.length; i++) {
138
141
  var str = lt[i];
@@ -141,30 +144,30 @@ Tpl.prototype.init_after = function(config) {
141
144
  this.regex_in.push(new RegExp(rx_in, "gi"));
142
145
  var str_in = str.split("").join("·") + "·";
143
146
  this.str_in.push(str_in);
144
- var rx_out = str_in.replace("\\", "\\\\").replace("$", "\\$").replace("[", "\\[").replace("]", "\\]")
145
- .replace(
146
- "{", "\\{").replace("}", "\\}").replace("/", "\\/").replace("*", "\\*");
147
+ var rx_out = str_in.replace("\\", "\\\\").replace("$", "\\$").replace("[", "\\[").replace("]", "\\]").replace(
148
+ "{", "\\{").replace("}", "\\}").replace("/", "\\/").replace("*", "\\*");
147
149
  this.regex_out.push(new RegExp(rx_out, "gi"));
148
150
  this.str_out.push(str.replace("\\", ""));
149
151
  }
150
152
  }
151
153
 
152
154
  /**
153
- * 初始化
154
- * @param {Object} config 配置参数
155
+ * 初始化模板
156
+ * @param {Object} config - 配置参数
155
157
  */
156
- Tpl.prototype.init = function(config) {
157
- this.init_before(config);
158
- this.init_main(config);
159
- this.init_after(config);
158
+ Tpl.prototype.init = function (config) {
159
+ this._initBefore(config);
160
+ this._initMain(config);
161
+ this._initAfter(config);
160
162
  }
161
163
 
162
164
  /**
163
- * 转译字符
164
- * @param {String} body 字符串
165
- * @param {Boolean} restore 是否还原
165
+ * 转义字符
166
+ * @param {string} body - 字符串
167
+ * @param {boolean} restore - 是否还原
168
+ * @returns {string} 转义后的字符串
166
169
  */
167
- Tpl.prototype.change = function(body, restore) {
170
+ Tpl.prototype.escape = function (body, restore) {
168
171
  if (!body) {
169
172
  return body
170
173
  }
@@ -181,18 +184,18 @@ Tpl.prototype.change = function(body, restore) {
181
184
  }
182
185
 
183
186
  /**
184
- * 渲染模板(之前)
185
- * @param {String} body 模板
186
- * @param {Object} model 数据模型
187
- * @param {Object} options 配置参数
188
- * @return {String} 渲染结果
187
+ * 渲染前处理
188
+ * @param {string} body - 模板内容
189
+ * @param {Object} model - 数据模型
190
+ * @param {Object} options - 配置参数
191
+ * @returns {string} 渲染结果
189
192
  */
190
- Tpl.prototype.render_before = function(body, model, options) {
193
+ Tpl.prototype._renderBefore = function (body, model, options) {
191
194
  var ret = "";
192
195
  if (options && options.cache) {
193
196
  var f = options.cache_filename;
194
197
  if (f) {
195
- if (f.replace('./', '').indexOf('.') == -1 && !f.endWith(this.config.cache_extname)) {
198
+ if (f.replace('./', '').indexOf('.') == -1 && !f.endsWith(this.config.cache_extname)) {
196
199
  f += this.config.cache_extname;
197
200
  }
198
201
  var file = f.fullname(this.config.cache_root);
@@ -206,10 +209,11 @@ Tpl.prototype.render_before = function(body, model, options) {
206
209
  };
207
210
 
208
211
  /**
209
- * 用于注入全局函数
210
- * @param {Object} m
212
+ * 注入全局函数前处理
213
+ * @param {Object} m - 模型对象
214
+ * @returns {Object} 处理后的模型
211
215
  */
212
- Tpl.prototype.loadFunc_before = function(m) {
216
+ Tpl.prototype._loadFuncBefore = function (m) {
213
217
  // m.$i18n = function(key) {
214
218
  // return $.i18n(key);
215
219
  // }
@@ -217,38 +221,44 @@ Tpl.prototype.loadFunc_before = function(m) {
217
221
  }
218
222
 
219
223
  /**
220
- * 加载函数
221
- * @param {Object} m 模型
224
+ * 加载函数到模型
225
+ * @param {Object} m - 模型对象
226
+ * @returns {Object} 处理后的模型
222
227
  */
223
- Tpl.prototype.loadFunc = function(m) {
224
- this.loadFunc_before(m);
228
+ Tpl.prototype.loadFunc = function (m) {
229
+ this._loadFuncBefore(m);
225
230
  var _this = this;
226
- m.view = function(file, model, options) {
231
+ m.view = function (file, model, options) {
227
232
  return _this.view(file, Object.assign({}, m, model), options);
228
233
  }
229
- m.render = function(body, model, options) {
234
+ m.render = function (body, model, options) {
230
235
  return _this.render(body, Object.assign({}, m, model), options);
231
236
  }
232
- m.hook_action = function(name, ...args) {
237
+ m.hookAction = function (name, ...args) {
233
238
  return $.hook.runAction(name, m, ...args);
234
239
  }
235
- m.hook_filter = function(name, content, ...args) {
240
+ m.hookFilter = function (name, content, ...args) {
236
241
  if (!content) {
237
242
  content = "";
238
243
  }
239
244
  return $.hook.runFilter(name, m, content, ...args);
240
245
  }
246
+ if (global.$ && $.lang) {
247
+ m.$t = function (key, ...args) {
248
+ return $.lang.get(key, ...args);
249
+ }
250
+ }
241
251
  return m;
242
252
  }
243
253
 
244
254
  /**
245
- * 渲染模板(主要)
246
- * @param {String} body 模板
247
- * @param {Object} model 数据模型
248
- * @param {Object} options 配置参数
249
- * @return {String} 渲染结果
255
+ * 渲染主处理
256
+ * @param {string} body - 模板内容
257
+ * @param {Object} model - 数据模型
258
+ * @param {Object} options - 配置参数
259
+ * @returns {string} 渲染结果
250
260
  */
251
- Tpl.prototype.render_main = function(body, model, options) {
261
+ Tpl.prototype._renderMain = function (body, model, options) {
252
262
  var ret = "";
253
263
  if (body) {
254
264
  var m = Object.assign({}, {
@@ -262,18 +272,18 @@ Tpl.prototype.render_main = function(body, model, options) {
262
272
  };
263
273
 
264
274
  /**
265
- * 渲染模板(之后)
266
- * @param {String} body 模板
267
- * @param {Object} model 数据模型
268
- * @param {Object} options 配置参数
269
- * @return {String} 渲染结果
275
+ * 渲染后处理
276
+ * @param {string} body - 模板内容
277
+ * @param {Object} model - 数据模型
278
+ * @param {Object} options - 配置参数
279
+ * @returns {string} 渲染结果
270
280
  */
271
- Tpl.prototype.render_after = function(body, model, options) {
281
+ Tpl.prototype._renderAfter = function (body, model, options) {
272
282
  if (body) {
273
283
  if (options) {
274
284
  var f = options.cache_filename;
275
285
  if (f) {
276
- if (f.replace('./', '').indexOf('.') == -1 && !f.endWith(this.config.cache_extname)) {
286
+ if (f.replace('./', '').indexOf('.') == -1 && !f.endsWith(this.config.cache_extname)) {
277
287
  f += this.config.cache_extname;
278
288
  }
279
289
  var file = f.fullname(this.config.cache_root);
@@ -285,18 +295,18 @@ Tpl.prototype.render_after = function(body, model, options) {
285
295
  };
286
296
 
287
297
  /**
288
- * 渲染模板
289
- * @param {String} body 模板
290
- * @param {Object} model 数据模型
291
- * @param {Object} options 配置参数
292
- * @return {String} view 渲染后的视图
298
+ * 渲染子模板
299
+ * @param {string} body - 模板内容
300
+ * @param {Object} model - 数据模型
301
+ * @param {Object} options - 配置参数
302
+ * @returns {string} 渲染结果
293
303
  */
294
- Tpl.prototype.renderSub = function(body, model, options) {
295
- var ret = this.render_before(body, model, options);
304
+ Tpl.prototype._renderSub = function (body, model, options) {
305
+ var ret = this._renderBefore(body, model, options);
296
306
  if (!ret) {
297
- ret = this.render_main(body, model, options);
307
+ ret = this._renderMain(body, model, options);
298
308
  if (ret) {
299
- ret = this.render_after(ret, model, options);
309
+ ret = this._renderAfter(ret, model, options);
300
310
  }
301
311
  }
302
312
  return ret;
@@ -304,49 +314,49 @@ Tpl.prototype.renderSub = function(body, model, options) {
304
314
 
305
315
  /**
306
316
  * 渲染模板
307
- * @param {String} body 模板
308
- * @param {Object} model 数据模型
309
- * @param {Object} options 配置参数
310
- * @return {String} view 渲染后的视图
317
+ * @param {string} body - 模板内容
318
+ * @param {Object} model - 数据模型
319
+ * @param {Object} options - 配置参数
320
+ * @returns {string} 渲染结果
311
321
  */
312
- Tpl.prototype.render = function(body, model, options) {
313
- body = this.change(body);
314
- body = this.renderSub(body, model, options);
315
- return this.change(body, true);
322
+ Tpl.prototype.render = function (body, model, options) {
323
+ body = this.escape(body);
324
+ body = this._renderSub(body, model, options);
325
+ return this.escape(body, true);
316
326
  };
317
327
 
318
328
  /**
319
- * 编译模板并返回渲染函数
320
- * @param {String} body 模板
321
- * @param {Object} options 配置参数
322
- * @return {Function} 渲染函数
329
+ * 编译模板
330
+ * @param {string} body - 模板内容
331
+ * @param {Object} options - 配置参数
332
+ * @returns {Function} 渲染函数
323
333
  */
324
- Tpl.prototype.compile = function(body, options) {
334
+ Tpl.prototype.compile = function (body, options) {
325
335
  return template.compile(body, options);
326
336
  };
327
337
 
328
338
  /**
329
339
  * 渲染模板文件
330
- * @param {String} file 模板文件路径
331
- * @param {Object} model 数据模型
332
- * @param {Object} options 配置参数
333
- * @return {String} 渲染后的视图
340
+ * @param {string} file - 模板文件路径
341
+ * @param {Object} model - 数据模型
342
+ * @param {Object} options - 配置参数
343
+ * @returns {string} 渲染结果
334
344
  */
335
- Tpl.prototype.view = function(file, model, options) {
336
- if (file.replace('./', '').indexOf('.') === -1 && !file.endWith(this.config.extname)) {
345
+ Tpl.prototype.view = function (file, model, options) {
346
+ if (file.replace('./', '').indexOf('.') === -1 && !file.endsWith(this.config.extname)) {
337
347
  file += this.config.extname;
338
348
  }
339
- var f = file.fullname(this.dir + 'diy');
349
+ var f = file.fullname('diy'.fullname(this.dir));
340
350
  if (!f.hasFile()) {
341
- f = file.fullname(this.config.default_dir + 'diy');
351
+ f = file.fullname('diy'.fullname(this.config.default_dir));
342
352
  if (!f.hasFile()) {
343
- f = file.fullname(this.dir + this.current_theme);
353
+ f = file.fullname(this.current_theme.fullname(this.dir));
344
354
  if (!f.hasFile()) {
345
- f = file.fullname(this.dir + this.config.default_theme);
355
+ f = file.fullname(this.config.default_theme.fullname(this.dir));
346
356
  if (!f.hasFile()) {
347
- f = file.fullname(this.config.default_dir + this.current_theme);
357
+ f = file.fullname(this.current_theme.fullname(this.config.default_dir));
348
358
  if (!f.hasFile()) {
349
- f = file.fullname(this.config.default_dir + this.config.default_theme);
359
+ f = file.fullname(this.config.default_theme.fullname(this.config.default_dir));
350
360
  }
351
361
  }
352
362
  }
@@ -359,54 +369,55 @@ Tpl.prototype.view = function(file, model, options) {
359
369
  message: f + "文件不存在!"
360
370
  }
361
371
  }
362
- var body = f.loadText();
363
- if (body) {
364
- body = this.change(body);
365
- body = this.renderSub(body, model, options);
366
- body = this.change(body, true);
367
- return body;
368
- } else {
369
- return "";
372
+ else {
373
+ var body = f.loadText();
374
+ if (body) {
375
+ body = this.escape(body);
376
+ body = this._renderSub(body, model, options);
377
+ body = this.escape(body, true);
378
+ return body;
379
+ }
370
380
  }
381
+ return "";
371
382
  };
372
383
 
373
384
  /**
374
- * 设置视图背包成员
375
- * @param {Object} obj 设置的对象
385
+ * 设置视图数据
386
+ * @param {Object} obj - 要设置的数据对象
376
387
  */
377
- Tpl.prototype.set = function(obj) {
388
+ Tpl.prototype.set = function (obj) {
378
389
  $.push(this.viewBag, obj, true);
379
390
  };
380
391
 
381
392
  /**
382
- * 删除视图背包成员
383
- * @param {Array|String} arrOrStr 删除的键或键数组
393
+ * 删除视图数据
394
+ * @param {Array|string} keys - 要删除的键或键数组
384
395
  */
385
- Tpl.prototype.del = function(arrOrStr) {
386
- if (typeof(arrOrStr) == 'string') {
387
- delete this.viewBag[arrOrStr];
396
+ Tpl.prototype.del = function (keys) {
397
+ if (typeof (keys) == 'string') {
398
+ delete this.viewBag[keys];
388
399
  } else {
389
- arr.map(function(k) {
400
+ keys.map(function (k) {
390
401
  delete this.viewBag[k];
391
402
  });
392
403
  }
393
404
  };
394
405
 
395
406
  /**
396
- * 获取视图背包成员
397
- * @param {String} key 获取的对象键名
398
- * @return {Object} 值
407
+ * 获取视图数据
408
+ * @param {string} key - 数据键名
409
+ * @returns {any} 数据值
399
410
  */
400
- Tpl.prototype.get = function(key) {
411
+ Tpl.prototype.get = function (key) {
401
412
  return this.viewBag[key];
402
413
  };
403
414
 
404
415
  /**
405
416
  * 清除缓存
406
- * @param {Object} path 检索的路径
407
- * @param {Object} file 文件名
417
+ * @param {string} path - 缓存路径
418
+ * @param {string} file - 文件名
408
419
  */
409
- Tpl.prototype.clear_cache = function(path, file) {
420
+ Tpl.prototype.clearCache = function (path, file) {
410
421
  var cg = this.config;
411
422
  var root = cg.cache_root;
412
423
  var dir = path ? path.fullname(root) : root;
@@ -421,9 +432,11 @@ Tpl.prototype.clear_cache = function(path, file) {
421
432
  });
422
433
  };
423
434
 
424
- if (global.$) {
435
+ if (global.$ && !$.Tpl) {
425
436
  $.Tpl = Tpl;
426
437
  $.tpl = new Tpl();
427
438
  }
428
439
 
429
- module.exports = Tpl;
440
+ module.exports = {
441
+ Tpl
442
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_tpl",
3
- "version": "2.4.4",
3
+ "version": "2.4.6",
4
4
  "description": "这是超级美眉模板帮助类模块,用于MVC模式下的视图渲染",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -28,6 +28,6 @@
28
28
  "homepage": "https://gitee.com/qiuwenwu91/mm_tpl#readme",
29
29
  "dependencies": {
30
30
  "art-template": "^4.13.4",
31
- "mm_logs": "^1.5.3"
31
+ "mm_expand": "^1.9.7"
32
32
  }
33
33
  }
@@ -1,38 +1,3 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>${globalBag.name}</title>
6
- </head>
7
- <body>
8
- <h5>${viewBag.name}</h5>
9
- <p>${@hook_filter('test', '你真的是人才!')}</p>
10
- <p><!--{@hook_filter('test', '你真的是人才!', {key: '123'})}--></p>
11
- <ul>
12
- ${loop arr value idx}
13
- <li>\${ value }</li>
14
- ${/loop}
15
- </ul>
16
- <ul>
17
- <!--[ for(var i = 0; i < arr.length; i++) { ]-->
18
- <li>${ arr[i] }</li>
19
- <!--[ } ]-->
20
- </ul>
21
- <ul>
22
- <!--{loop arr value idx}-->
23
- <li>\${ value }</li>
24
- <!--{/loop}-->
25
- </ul>
26
- <script type="text/javascript">
27
- /*[loop arr value idx]*/
28
- var a_${idx} = ${value};
29
- /*[/loop]*/
30
- </script>
31
- ${viewBag.name}
32
- ## "计算" ##
33
- 123123'"""#
34
- "price" + "NIHAO"
35
- #"""'
36
- ## "#计算" ##
37
- </body>
38
- </html>
1
+ <div>
2
+ <p>这是一个广告位!</p>
3
+ </div>
@@ -1,11 +1,15 @@
1
1
  <div class="bar_user">
2
- ${@hook_filter('test', hook_action('test', '好的'), '真的')}
2
+ ${@hookFilter('test', hookAction('test', '好的'), '真的')}
3
3
  <div>用户ID:${viewBag.user_id}</div>
4
4
  <div>当前项目ID:${viewBag.project_id}</div>
5
5
  <div>${message}</div>
6
6
  </div>
7
7
 
8
8
  <div class="bar">导航栏</div>
9
+ <!-- 广告位 -->
10
+ <div class="ad">
11
+ ${@view('./ad')}
12
+ </div>
9
13
  <style>
10
14
  .bar {
11
15
  font-weight: 800;
@@ -2,7 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8">
5
- <title>${globalBag.name}</title>
5
+ <title>${globalBag.name}-游戏测试</title>
6
6
  </head>
7
7
  <body>
8
8
  <div>游戏主题</div>
package/test.js CHANGED
@@ -1,11 +1,11 @@
1
- const Tpl = require('./index.js');
1
+ const {Tpl} = require('./index.js');
2
2
 
3
3
  /**
4
4
  * 基础模板渲染测试函数
5
5
  * 演示简单的变量替换功能
6
6
  * @async
7
7
  */
8
- async function test() {
8
+ async function test1() {
9
9
  var tpl = new Tpl();
10
10
  var body = tpl.render("<a>${test} + 123123</a>", {
11
11
  test: 123
@@ -18,7 +18,7 @@ async function test() {
18
18
  * 演示模板中的循环功能
19
19
  * @async
20
20
  */
21
- async function test() {
21
+ async function test2() {
22
22
  var tpl = new Tpl();
23
23
  // 数组循环示例
24
24
  // var body = tpl.render("<a>${loop arr value idx} ${idx} ${ value } ${/loop} + 123123</a>", { arr: [123,234] });
@@ -42,8 +42,7 @@ async function test() {
42
42
  * 演示全局变量和视图渲染的使用
43
43
  * @async
44
44
  */
45
- async function test() {
46
- $.log.debug("测试开始")
45
+ async function test3() {
47
46
  var tpl = new Tpl();
48
47
  // 设置全局变量
49
48
  $.globalBag.name = "超级美眉Art模板引擎";
@@ -62,7 +61,7 @@ async function test() {
62
61
  * 演示带有动作和过滤器的钩子系统
63
62
  * @async
64
63
  */
65
- async function test() {
64
+ async function test4() {
66
65
  var tpl = new Tpl();
67
66
 
68
67
  // 设置全局变量
@@ -114,7 +113,7 @@ async function test() {
114
113
  }, 'article');
115
114
 
116
115
  // 使用缓存渲染视图
117
- var body = tpl.view("./ad", {
116
+ var body = tpl.view("./test", {
118
117
  arr: [123, 234],
119
118
  message: "hello world!"
120
119
  }, {
@@ -125,8 +124,20 @@ async function test() {
125
124
  });
126
125
  // 删除指定目录下的缓存文件
127
126
  // tpl.clear_cache('./mall');
128
- $.log.debug(body);
127
+ $.log.debug("渲染结果", body);
129
128
  }
130
129
 
131
130
  // 执行测试
132
- test();
131
+ async function demo() {
132
+ $.log.debug("测试开始");
133
+ $.log.debug("测试1");
134
+ await test1();
135
+ $.log.debug("测试2");
136
+ await test2();
137
+ $.log.debug("测试3");
138
+ await test3();
139
+ $.log.debug("测试4");
140
+ await test4();
141
+ }
142
+
143
+ demo();