|
@@ -313,13 +313,14 @@ export function removeSpace (str: string) {
|
|
|
}
|
|
|
|
|
|
// 文件大小格式化
|
|
|
-export function formatSize (size: string | number, pointLength = 2, units = ['B', 'K', 'M', 'G', 'TB']) {
|
|
|
+export function formatSize (size: string | number, pointLength = 2) {
|
|
|
+ const units = ['B', 'K', 'M', 'G', 'TB']
|
|
|
size = Number(size)
|
|
|
let unit: string | undefined = ''
|
|
|
while ((unit = units.shift()) && size > 1024) {
|
|
|
size = size / 1024
|
|
|
}
|
|
|
- return (unit === 'B' ? size : size.toFixed(pointLength === undefined ? 2 : pointLength)) + (unit || '')
|
|
|
+ return (unit === 'B' ? size : size.toFixed(pointLength)) + (unit || '')
|
|
|
}
|
|
|
|
|
|
// 文件类型转换
|
|
@@ -330,7 +331,13 @@ export function docTypeConvert (docType = 'pdf') {
|
|
|
xls: 'excel',
|
|
|
xlsx: 'excel',
|
|
|
ppt: 'ppt',
|
|
|
- pdf: 'pdf'
|
|
|
+ pdf: 'pdf',
|
|
|
+ 1: 'word', // doc
|
|
|
+ 2: 'pdf',
|
|
|
+ 3: 'excel', // xls
|
|
|
+ 4: 'ppt',
|
|
|
+ 5: 'txt',
|
|
|
+ 6: '其他'
|
|
|
}
|
|
|
const type = typeMap[docType]
|
|
|
return type || docType // map中不存在的,则返回原始类型
|