fix: file-icon

This commit is contained in:
puri-ph4tt 2023-11-28 16:47:38 +07:00 committed by Methapon2001
parent 9e889ccaa1
commit c69d1f6702
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
2 changed files with 31 additions and 42 deletions

View file

@ -127,43 +127,34 @@ export const useFileInfoStore = defineStore('info', () => {
}
function getType(mimeType: any): string {
if (mimeType === undefined) {
return 'unknow type'
} else {
if (mimeFileMapping.hasOwnProperty(mimeType)) {
return mimeFileMapping[mimeType].type
} else {
return 'unknow type'
}
}
return mimeType && mimeFileMapping.hasOwnProperty(mimeType)
? mimeFileMapping[mimeType].type
: 'unknown type'
}
function getFormatDate(dateTime: any): string {
if (dateTime === undefined) {
return 'unknow date'
} else {
const date = new Date(dateTime)
const result = date.toLocaleDateString('th-TH', {
year: 'numeric',
month: 'long',
day: 'numeric',
})
return result
return 'unknown date'
}
const date = new Date(dateTime)
return date.toLocaleDateString('th-TH', {
year: 'numeric',
month: 'long',
day: 'numeric',
})
}
function getSize(size: any): string {
if (size === undefined) {
return 'unknow size'
} else {
const units = ['B', 'KB', 'MB', 'GB', 'TB']
let i = 0
while (size >= 1024 && i < units.length - 1) {
size /= 1024
i++
}
return size.toFixed(2) + ' ' + units[i]
}
const units = ['B', 'KB', 'MB', 'GB', 'TB']
let i = 0
while (size >= 1024 && i < units.length - 1) {
size /= 1024
i++
}
return size.toFixed(2) + ' ' + units[i]
}
async function getFileInfo(data: EhrFile) {