Explorar o código

文件类型匹配

zhaoxiaohai %!s(int64=3) %!d(string=hai) anos
pai
achega
c320d1cbc5
Modificáronse 1 ficheiros con 6 adicións e 4 borrados
  1. 6 4
      utils/matchingFeilType.js

+ 6 - 4
utils/matchingFeilType.js

@@ -5,15 +5,17 @@ module.exports.fileList = function fileList(list) {
             word: ['doc', 'docx'],
             excel: ['xls', 'xlsx'],
             ppt: ['ppt', 'pptx'],
-            txt: ['txt'],
+            txt: ['txt','md','js','json'],
             pdf: ['pdf'],
             rar: ['7z', 'zip', 'rar', 'kz', 'ace', 'arj', 'bz2', 'cab', 'gz', 'iso', 'jar', 'lzh', 'tar', 'z'],
             folder: ['"folder"']
         },
         typeList = [];
     for (let key in suffixList) typeList.push(key);
-    
+
     for (let i = 0; i < list.length; i++) {
+        list[i].fileType = 'unknown';
+        list[i].cover = `/static/image/file/unknown.png`
         const suffix = list[i].postfix;
         if (suffix != "folder") {
             for (var key in suffixList) {
@@ -27,8 +29,8 @@ module.exports.fileList = function fileList(list) {
                 }
             }
         } else {
-            list[i].fileType = suffix == "folder" ? 'folder' : 'unknown';
-            list[i].cover = suffix == "folder" ? '/static/image/file/folder.png' : '/static/image/file/unknown.png';
+            list[i].fileType = "folder";
+            list[i].cover = `/static/image/file/folder.png`
         }
     }
     return list;