2023-11-23 17:59:17 +07:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
import { useFileInfoStore } from '@/stores/file-info-data'
|
|
|
|
|
|
|
|
|
|
const { mimeFileMapping } = useFileInfoStore()
|
|
|
|
|
|
2023-11-28 09:22:44 +07:00
|
|
|
defineProps<{ fileMimeType: string | undefined; size: string }>()
|
2023-11-23 17:59:17 +07:00
|
|
|
|
|
|
|
|
function getIcon(mimeType: string) {
|
|
|
|
|
if (mimeFileMapping.hasOwnProperty(mimeType)) {
|
|
|
|
|
return mimeFileMapping[mimeType].icon
|
|
|
|
|
} else {
|
|
|
|
|
return 'mdi-file-question-outline'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function getColor(mimeType: string) {
|
|
|
|
|
if (mimeFileMapping.hasOwnProperty(mimeType)) {
|
|
|
|
|
return mimeFileMapping[mimeType].color
|
|
|
|
|
} else {
|
|
|
|
|
return 'blue-11'
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function getSize(s: string) {
|
|
|
|
|
if (s === 'preview') {
|
|
|
|
|
return '6em'
|
|
|
|
|
}
|
2023-11-28 09:22:44 +07:00
|
|
|
if (s === 'list') {
|
|
|
|
|
return '2em'
|
|
|
|
|
}
|
2023-11-23 17:59:17 +07:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<q-icon
|
2023-11-28 09:22:44 +07:00
|
|
|
:name="fileMimeType && getIcon(fileMimeType)"
|
|
|
|
|
:color="fileMimeType && getColor(fileMimeType)"
|
2023-11-23 17:59:17 +07:00
|
|
|
:size="getSize(size)"
|
|
|
|
|
/>
|
|
|
|
|
</template>
|