Explorar el Código

变更令附件2

laiguoran hace 6 años
padre
commit
15100044c4
Se han modificado 2 ficheros con 21 adiciones y 2 borrados
  1. 14 0
      app/extend/helper.js
  2. 7 2
      config/config.default.js

+ 14 - 0
app/extend/helper.js

@@ -54,6 +54,20 @@ module.exports = {
     },
 
     /**
+     * 字节转换
+     * @param bytes 字节
+     * @return {string} 大小
+     */
+    bytesToSize(bytes) {
+        if (bytes === 0) return '0 B';
+        let k = 1024;
+        const sizes = ['B','KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
+        let i = Math.floor(Math.log(bytes) / Math.log(k));
+        //return (bytes / Math.pow(k, i)) + ' ' + sizes[i];
+        return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
+    },
+
+    /**
      * 显示排序符号
      *
      * @param {String} field - 字段名称

+ 7 - 2
config/config.default.js

@@ -101,8 +101,13 @@ module.exports = appInfo => {
 
     // 上传设置
     config.multipart = {
-        whitelist: ['.xls', '.xlsx', '.json'],
-        fileSize: '10mb',
+        whitelist: ['.json', '.txt',
+            '.xls', '.xlsx',
+            '.doc', '.docx',
+            '.pdf',
+            '.png', '.jpg', '.jpeg', '.gif', '.bmp',
+            '.zip', '.rar', '.7z'],
+        fileSize: '30mb',
     };
 
     // 是否压缩替换前端js