Merge branch 'phatt' into dev/front
This commit is contained in:
commit
6e77d30236
2 changed files with 31 additions and 42 deletions
|
|
@ -6,26 +6,24 @@ const { mimeFileMapping } = useFileInfoStore()
|
|||
defineProps<{ fileMimeType: string | undefined; size: string }>()
|
||||
|
||||
function getIcon(mimeType: string) {
|
||||
if (mimeFileMapping.hasOwnProperty(mimeType)) {
|
||||
return mimeFileMapping[mimeType].icon
|
||||
} else {
|
||||
return 'mdi-file-question-outline'
|
||||
}
|
||||
return mimeType && mimeFileMapping.hasOwnProperty(mimeType)
|
||||
? mimeFileMapping[mimeType].icon
|
||||
: 'mdi-file-question-outline'
|
||||
}
|
||||
function getColor(mimeType: string) {
|
||||
if (mimeFileMapping.hasOwnProperty(mimeType)) {
|
||||
return mimeFileMapping[mimeType].color
|
||||
} else {
|
||||
return 'blue-11'
|
||||
}
|
||||
return mimeType && mimeFileMapping.hasOwnProperty(mimeType)
|
||||
? mimeFileMapping[mimeType].color
|
||||
: 'blue-11'
|
||||
}
|
||||
function getSize(s: string) {
|
||||
if (s === 'preview') {
|
||||
return '6em'
|
||||
function getIconSize(s: string) {
|
||||
type SizeMapping = {
|
||||
[key: string]: string
|
||||
}
|
||||
if (s === 'list') {
|
||||
return '2em'
|
||||
const sizeMapping: SizeMapping = {
|
||||
preview: '6em',
|
||||
list: '2em',
|
||||
}
|
||||
return sizeMapping[s]
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
@ -33,6 +31,6 @@ function getSize(s: string) {
|
|||
<q-icon
|
||||
:name="fileMimeType && getIcon(fileMimeType)"
|
||||
:color="fileMimeType && getColor(fileMimeType)"
|
||||
:size="getSize(size)"
|
||||
:size="getIconSize(size)"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue