refactor: clean code and handle
This commit is contained in:
parent
aa63e9c8c5
commit
e682485bce
3 changed files with 40 additions and 28 deletions
|
|
@ -139,23 +139,31 @@ export const useFileInfoStore = defineStore('info', () => {
|
|||
}
|
||||
|
||||
function getFormatDate(dateTime: any): string {
|
||||
const date = new Date(dateTime)
|
||||
const result = date.toLocaleDateString('th-TH', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
})
|
||||
return result
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
function getSize(size: any): string {
|
||||
const units = ['B', 'KB', 'MB', 'GB', 'TB']
|
||||
let i = 0
|
||||
while (size >= 1024 && i < units.length - 1) {
|
||||
size /= 1024
|
||||
i++
|
||||
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]
|
||||
}
|
||||
return size.toFixed(2) + ' ' + units[i]
|
||||
}
|
||||
|
||||
async function getFileInfo(data: EhrFile) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue