refactor: file info store (Mime type) color & icon

This commit is contained in:
puri-ph4tt 2023-11-23 17:59:17 +07:00
parent 04b87f6b74
commit 37b8f64027
2 changed files with 196 additions and 0 deletions

View file

@ -0,0 +1,35 @@
<script setup lang="ts">
import { useFileInfoStore } from '@/stores/file-info-data'
const { mimeFileMapping } = useFileInfoStore()
defineProps<{ fileMimeType: any; size: string }>()
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'
}
}
</script>
<template>
<q-icon
:name="getIcon(fileMimeType)"
:color="getColor(fileMimeType)"
:size="getSize(size)"
/>
</template>