mm_os 2.4.6 → 2.4.7

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.
@@ -1,10 +1,12 @@
1
1
  {
2
2
  // 应用于,根据应用而判断使用
3
3
  "app": "admin",
4
- // 位置 side侧边栏、main主体、float浮动栏、header头部、footer尾部
5
- "position": "main",
6
4
  // 名称, 用于动态增删改配置
7
5
  "name": "{0}",
6
+ // 页面位置
7
+ "pages": ["/admin/index"],
8
+ // 位置 side侧边栏、main主体、float浮动栏、header头部、footer尾部
9
+ "position": "main",
8
10
  // 标题, 用于查询时
9
11
  "title": "示例组件(挂件)",
10
12
  // 描述, 用于介绍该组件的作用
@@ -20,10 +20,12 @@ class Drive extends Item {
20
20
  this.config = {
21
21
  // 应用于,根据应用而判断使用
22
22
  "app": "admin",
23
- // 位置 side侧边栏、main主体、float浮动栏、header头部、footer尾部
24
- "position": "main",
25
23
  // 名称, 用于动态增删改配置
26
24
  "name": "demo",
25
+ // 页面位置
26
+ "pages": ["/admin/index"],
27
+ // 位置 side侧边栏、main主体、float浮动栏、header头部、footer尾部
28
+ "position": "main",
27
29
  // 标题, 用于查询时
28
30
  "title": "示例组件",
29
31
  // 描述, 用于介绍该组件的作用
@@ -46,7 +48,6 @@ class Drive extends Item {
46
48
  }
47
49
  };
48
50
 
49
-
50
51
  /**
51
52
  * 创建一个参数模型
52
53
  */
@@ -54,10 +55,12 @@ Drive.prototype.model = function() {
54
55
  return {
55
56
  // 应用于,根据应用而判断使用
56
57
  "app": "admin",
57
- // 位置 side侧边栏、main主体、float浮动栏、header头部、footer尾部
58
- "position": "main",
59
58
  // 名称, 用于动态增删改配置
60
59
  "name": "demo",
60
+ // 页面位置
61
+ "pages": ["/admin/index"],
62
+ // 位置 side侧边栏、main主体、float浮动栏、header头部、footer尾部
63
+ "position": "main",
61
64
  // 标题, 用于查询时
62
65
  "title": "示例组件",
63
66
  // 描述, 用于介绍该组件的作用
@@ -26,7 +26,7 @@ class Component extends Index {
26
26
  * 新建脚本
27
27
  * @param {String} file 文件
28
28
  */
29
- Drive.prototype.new_script = function(file) {
29
+ Component.prototype.new_script = function(file) {
30
30
  var fl = __dirname + "/script.js";
31
31
  if (fl.hasFile()) {
32
32
  var text = fl.loadText();
@@ -81,28 +81,30 @@ Component.prototype.load_list = function(list) {
81
81
 
82
82
  /**
83
83
  * 执行渲染
84
- * @param {String} app 应用
84
+ * @param {String} page 页面
85
85
  * @param {String} position 位置
86
86
  * @param {String} position position
87
87
  * @param {Object} ctx 请求上下文
88
88
  * @param {Object} db 数据管理器,如: { next: async function{}, ret: {} }
89
89
  * @return {String}
90
90
  */
91
- Component.prototype.render = async function(app, position, ctx, db) {
91
+ Component.prototype.render = async function(page, position, ctx, db) {
92
92
  var html = "";
93
93
  var list = this.list;
94
94
  for (var i = 0; i < list.length; i++) {
95
95
  var o = list[i];
96
96
  var cg = o.config;
97
- if (cg.state && cg.app == app && cg.position == position) {
98
- var ret;
99
- try {
100
- ret = await o.run('main', ctx, db);
101
- } catch (error) {
102
- $.log.error("组件渲染失败", o.config.name, error);
103
- }
104
- if (ret) {
105
- html += "\n" + ret;
97
+ if (cg.state && cg.position == position) {
98
+ if(cg.pages && cg.pages.indexOf(page) !== -1){
99
+ var ret;
100
+ try {
101
+ ret = await o.run('main', ctx, db);
102
+ } catch (error) {
103
+ $.log.error("组件渲染失败", o.config.name, error);
104
+ }
105
+ if (ret) {
106
+ html += "\n" + ret;
107
+ }
106
108
  }
107
109
  }
108
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "2.4.6",
3
+ "version": "2.4.7",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {