hrms-edm/Services/client/src/components/FileIcon.vue

37 lines
900 B
Vue
Raw Normal View History

<script setup lang="ts">
import { useFileInfoStore } from '@/stores/file-info-data'
const { mimeFileMapping } = useFileInfoStore()
defineProps<{ fileMimeType: string | undefined; size: string }>()
function getIcon(mimeType: string) {
2023-11-28 16:47:38 +07:00
return mimeType && mimeFileMapping.hasOwnProperty(mimeType)
? mimeFileMapping[mimeType].icon
: 'mdi-file-question-outline'
}
function getColor(mimeType: string) {
2023-11-28 16:47:38 +07:00
return mimeType && mimeFileMapping.hasOwnProperty(mimeType)
? mimeFileMapping[mimeType].color
: 'blue-11'
}
2023-11-28 16:47:38 +07:00
function getIconSize(s: string) {
type SizeMapping = {
[key: string]: string
}
2023-11-28 16:47:38 +07:00
const sizeMapping: SizeMapping = {
preview: '6em',
list: '2em',
}
2023-11-28 16:47:38 +07:00
return sizeMapping[s]
}
</script>
<template>
<q-icon
:name="fileMimeType && getIcon(fileMimeType)"
:color="fileMimeType && getColor(fileMimeType)"
2023-11-28 16:47:38 +07:00
:size="getIconSize(size)"
/>
</template>