mm_os 2.7.2 → 2.7.4

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.
@@ -19,6 +19,8 @@
19
19
  "template": "./component.html",
20
20
  // 状态, 0为未开启 1为开启
21
21
  "state": 1,
22
+ // 配置
23
+ "options": [],
22
24
  // 定位 由后台指定的展示位置
23
25
  "location": [{
24
26
  "page": "/admin/index",
@@ -1,3 +1,4 @@
1
+ const compressing = require('compressing');
1
2
  const Item = require('mm_machine').Item;
2
3
 
3
4
  /**
@@ -38,6 +39,8 @@ class Drive extends Item {
38
39
  "template": "./component.html",
39
40
  // 状态, 0为未开启 1为开启
40
41
  "state": 1,
42
+ // 配置
43
+ "options": [],
41
44
  // 定位 由后台指定的展示位置
42
45
  "location": []
43
46
  }
@@ -69,6 +72,8 @@ Drive.prototype.model = function() {
69
72
  "template": "./component.html",
70
73
  // 状态, 0为未开启 1为开启
71
74
  "state": 1,
75
+ // 配置
76
+ "options": [],
72
77
  // 定位 由后台指定的展示位置
73
78
  "location": [{
74
79
  "page": "/admin/index",
@@ -105,6 +110,29 @@ Drive.prototype.new_script = function(file) {
105
110
  }
106
111
  };
107
112
 
113
+ /**
114
+ * 获取配置参数
115
+ * @param {Object} 设置配置
116
+ * @return {Object} 返回配置参数
117
+ */
118
+ Drive.prototype.design_option = function(body) {
119
+ var cg = this.config;
120
+ if (Array.isArray(body)) {
121
+ cg.options = body;
122
+ } else {
123
+ var options = cg.options || [];
124
+ var option = options.getObj({
125
+ name: body.name
126
+ });
127
+ if (option) {
128
+ Object.assign(option, body);
129
+ } else {
130
+ options.push(body);
131
+ }
132
+ cg.options = options;
133
+ }
134
+ }
135
+
108
136
  /**
109
137
  * 组件主函数
110
138
  * @param {Object} ctx 请求上下文
@@ -117,4 +145,20 @@ Drive.prototype.main = async function(ctx, db) {
117
145
  return db.tpl.view(html_file.fullname(this.dir), model);
118
146
  };
119
147
 
148
+ /**
149
+ * 压缩主题模板
150
+ * @param {String} 要压缩的目录
151
+ * @returns {String} 打包成功返回压缩包文件地址
152
+ */
153
+ Drive.prototype.zip = async function(zip_dir = "/static/file/zip/") {
154
+ var dir = this.filename.dirname();
155
+ var file = ("./" + this.config.name + '.zip').fullname(zip_dir);
156
+ file.addDir();
157
+ var done = await compressing.zip.compressDir(dir, file);
158
+ if (file.hasFile()) {
159
+ return file;
160
+ }
161
+ return null;
162
+ }
163
+
120
164
  module.exports = Drive;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "2.7.2",
3
+ "version": "2.7.4",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -45,7 +45,6 @@
45
45
  "mm_mongodb": "^1.4.2",
46
46
  "mm_mqtt": "^1.0.6",
47
47
  "mm_mysql": "^1.8.9",
48
- "mm_os": "^2.6.4",
49
48
  "mm_redis": "^1.4.2",
50
49
  "mm_ret": "^1.3.9",
51
50
  "mm_session": "^1.4.8",