refactor: file info store (Mime type) color & icon
This commit is contained in:
parent
04b87f6b74
commit
37b8f64027
2 changed files with 196 additions and 0 deletions
35
Services/client/src/components/FileIcon.vue
Normal file
35
Services/client/src/components/FileIcon.vue
Normal 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue