yyzone-bip
Version:
升级新的ui标准后的yyzone库
46 lines (45 loc) • 1.38 kB
JavaScript
function getFileType(suffix) {
let type = 'other';
switch (true) {
case /(jpg|jpeg|png|gif|raw|bmp|pcx|tif|tga|exif)$/.test(suffix):
type = 'pic';
break;
case /(doc|docx|docm|dotx)$/.test(suffix):
type = 'word';
break;
case /(xls|xlsx|xlsm|xlsb|xlam|xltx|xltm|xlt)$/.test(suffix):
type = 'exl';
break;
case /(ppt|pptx|pptm|ppsx|pps|ppsm)$/.test(suffix):
type = 'ppt';
break;
case /(txt)$/.test(suffix):
type = 'txt';
break;
case /(sketch)$/.test(suffix):
type = 'sketch';
break;
case /(psd|pdd)$/.test(suffix):
type = 'ps';
break;
case /(ai)$/.test(suffix):
type = 'ai';
break;
case /(avi|mov|qt|asf|rm|mpeg|mpg|dat|rmvb|wmv|mp4)$/.test(suffix):
type = 'movie';
break;
case /(mp3|ogg|wav|cda|wma)$/.test(suffix):
type = 'music';
break;
case /(rar|zip|7z|gz|xz)$/.test(suffix):
type = 'zip';
break;
case /(pdf)$/.test(suffix):
type = 'pdf';
break;
default:
type = 'other';
}
return type
}
export { getFileType }