Explorar o código

获取压缩图或缩略图

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

+ 14 - 2
utils/matchingFeilType.js

@@ -1,11 +1,11 @@
-module.exports.fileList = function fileList(list) {
+function fileList(list) {
     let suffixList = {
             image: ['png', 'jpg', 'jpeg', 'bmp', 'gif', 'webp', 'svg', 'tiff'],
             video: ['mp4', 'ogg', 'webm'],
             word: ['doc', 'docx'],
             excel: ['xls', 'xlsx'],
             ppt: ['ppt', 'pptx'],
-            txt: ['txt','md','js','json'],
+            txt: ['txt', 'md', 'js', 'json'],
             pdf: ['pdf'],
             rar: ['7z', 'zip', 'rar', 'kz', 'ace', 'arj', 'bz2', 'cab', 'gz', 'iso', 'jar', 'lzh', 'tar', 'z'],
             folder: ['"folder"']
@@ -34,4 +34,16 @@ module.exports.fileList = function fileList(list) {
         }
     }
     return list;
+};
+
+//得到缩略图或者压缩图  getType默认得到缩略图传true得到压缩图
+function getSpecifiedImage(obj, getType = false) {
+    let type = getType ? 'compressed' : 'thumbnail';
+    let imgObj = obj.subfiles.find(v => v.type == type);
+    return imgObj.url;
+}
+
+module.exports = {
+    fileList,
+    getSpecifiedImage
 }