mm_os 2.7.3 → 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.
- package/core/com/component/drive.js +40 -0
- package/package.json +1 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
const compressing = require('compressing');
|
|
1
2
|
const Item = require('mm_machine').Item;
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -109,6 +110,29 @@ Drive.prototype.new_script = function(file) {
|
|
|
109
110
|
}
|
|
110
111
|
};
|
|
111
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
|
+
|
|
112
136
|
/**
|
|
113
137
|
* 组件主函数
|
|
114
138
|
* @param {Object} ctx 请求上下文
|
|
@@ -121,4 +145,20 @@ Drive.prototype.main = async function(ctx, db) {
|
|
|
121
145
|
return db.tpl.view(html_file.fullname(this.dir), model);
|
|
122
146
|
};
|
|
123
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
|
+
|
|
124
164
|
module.exports = Drive;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_os",
|
|
3
|
-
"version": "2.7.
|
|
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",
|