mm_os 1.6.1 → 1.6.3

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.
@@ -12,9 +12,6 @@ if (!$.dict) {
12
12
  }
13
13
  }
14
14
 
15
- var dir = '/app/sys/static/doc/';
16
- var url_path = "/sys/doc/";
17
-
18
15
  /**
19
16
  * Api接口驱动类
20
17
  * @extends {Item}
@@ -29,7 +26,10 @@ class Drive extends Item {
29
26
  constructor(dir) {
30
27
  super(dir, __dirname);
31
28
  this.default_file = "./api.json";
32
-
29
+
30
+ this.save_dir = '/static/file/';
31
+ this.url_path = "/file/";
32
+
33
33
  // oauth身份验证配置 + 函数
34
34
  this.oauth;
35
35
  // param参数配置 + 函数
@@ -329,20 +329,17 @@ Drive.prototype.save_file = function(files) {
329
329
  var f = files.file;
330
330
  // 创建可读流
331
331
  var stamp = Date.now();
332
- var name = f.name;
333
- file = path.join($.runPath, dir, name);
334
- const fileDir = path.join($.runPath, dir);
335
- if (!fs.existsSync(fileDir)) {
336
- fs.mkdirSync(fileDir, err => {
337
- $.log.error('创建失败', err);
338
- });
339
- }
332
+ var name = f.name || f.originalFilename;
333
+ file = ("./" + name).fullname(this.save_dir);
334
+ file.addDir();
340
335
  // 创建写入流
336
+ var readStream = fs.createReadStream(f.filepath);
337
+
341
338
  try {
342
339
  const writeStream = fs.createWriteStream(file);
343
340
  readStream.pipe(writeStream);
344
341
  // writeStream.close();
345
- url = url_path + name;
342
+ url = this.url_path + name;
346
343
  } catch (err) {
347
344
  $.log.error('保存文件失败', err);
348
345
  }
@@ -661,6 +661,7 @@ Drive.prototype.get_format = async function(db) {
661
661
  Drive.prototype.import_main = async function(db, file) {
662
662
  var params = await this.get_params(db);
663
663
  var format = await this.get_format(db);
664
+
664
665
  file = file.replace(this.url_path, this.save_dir);
665
666
  var path;
666
667
  if ($.config.path) {
@@ -700,7 +701,7 @@ Drive.prototype.import_main = async function(db, file) {
700
701
  var o = jarr[i];
701
702
  var qy = {};
702
703
  qy[key] = o[key];
703
- var n = await db.set(qy, o);
704
+ var n = await db.addOrSet(qy, o);
704
705
  if (n < 1) {
705
706
  errors.push(db.error);
706
707
  list_error.push(o);
@@ -787,8 +788,6 @@ Drive.prototype.export_main = async function(db, query, body) {
787
788
  fields = query.field;
788
789
  }
789
790
  var params = await this.get_params(db, fields);
790
-
791
- console.log("参数", params, fields);
792
791
  var format = await this.get_format(db);
793
792
 
794
793
  file = file.fullname(path);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "koa-send": "^5.0.1",
36
36
  "koa-websocket": "^7.0.0",
37
37
  "mm_check": "^1.4.4",
38
- "mm_excel": "^1.0.9",
38
+ "mm_excel": "^1.1.1",
39
39
  "mm_expand": "^1.5.6",
40
40
  "mm_html": "^1.1.1",
41
41
  "mm_koa_proxy": "^1.0.0",