export default {
    fileList (list) {
        let suffixList = {
            image: ['png', 'jpg', 'jpeg', 'bmp', 'gif','JPG', 'webp', 'svg', 'tiff'],
            video: ['mp4', 'ogg', 'webm'],
            word: ['doc', 'docx'],
            excel: ['xls', 'xlsx'],
            PPT: ['ppt', 'pptx'],
            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 = require('@/assets/file_icons/unknow.png')
            // list[i].cover = `/static/image/file/unknown.png`
            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 = require('@/assets/file_icons/' + key + '.png');
                        }

                    }
                }
            } else {
                list[i].fileType = "folder";
                list[i].cover = require('@/assets/file_icons/folder.png');
            }
        }
        return list;
    },
    getSpecifiedImage (obj, getType = false) {
        let type = getType ? 'compressed' : 'thumbnail';
        let imgObj = obj.subfiles.find(v => v.type == type);
        return imgObj.url;
    }
}