|
@@ -0,0 +1,35 @@
|
|
|
+module.exports.fileList = 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'],
|
|
|
+ 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++) {
|
|
|
+ const suffix = list[i].postfix;
|
|
|
+ if (suffix != "folder") {
|
|
|
+ for (var key in suffixList) {
|
|
|
+ if (suffixList[key].some(value => value == suffix)) {
|
|
|
+ list[i].fileType = key;
|
|
|
+ if (key == 'image') {
|
|
|
+ list[i].cover = list[i].url;
|
|
|
+ } else if (typeList.includes(key)) {
|
|
|
+ list[i].cover = `/static/image/file/${key}.png`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ list[i].fileType = suffix == "folder" ? 'folder' : 'unknown';
|
|
|
+ list[i].cover = suffix == "folder" ? '/static/image/file/folder.png' : '/static/image/file/unknown.png';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+}
|