






















/** 文件识别 */
export const getFileType = (fileName: string) => {
if (!fileName) return 'other';
//根据文件名提取后缀名
const index = fileName.lastIndexOf('.');
const ext = fileName.substr(index + 1).toLowerCase();
const enumsFileType: Record<string, any> = {
image: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'bmp', 'svg', 'tiff'],
pdf: ['pdf'],
excel: ['xlsx'],
word: ['docx', 'doc'],
ppt: ['ppt', 'pptx'],
video: ['mp4', 'avi', 'mov']
};
for (const key in enumsFileType) {
if (enumsFileType[key].includes(ext)) {
return key;
}
}
return 'other';
};
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。