refactor: code readability
This commit is contained in:
parent
5a7c56a67e
commit
47fe2f8f0a
1 changed files with 16 additions and 27 deletions
|
|
@ -1,6 +1,6 @@
|
|||
<script setup lang="ts">
|
||||
import { useFileInfoStore } from '@/stores/file-info-data'
|
||||
import mime from 'mime'
|
||||
import { useFileInfoStore } from '@/stores/file-info-data'
|
||||
|
||||
const { mimeFileMapping } = useFileInfoStore()
|
||||
|
||||
|
|
@ -11,44 +11,33 @@ defineProps<{
|
|||
}>()
|
||||
|
||||
function getIcon(mimeType: string | undefined, fileName: string | undefined) {
|
||||
if (mimeType === undefined) {
|
||||
return 'mdi-file-question-outline'
|
||||
}
|
||||
if (!mimeType) return 'mdi-file-question-outline'
|
||||
|
||||
const extension = mime.getExtension(mimeType)
|
||||
|
||||
if (extension) return mimeFileMapping[mimeType].icon
|
||||
if (fileName && fileName.includes('.')) return 'mdi-file-outline'
|
||||
|
||||
const extFomMime = mime.getExtension(mimeType)
|
||||
if (extFomMime) {
|
||||
return mimeFileMapping[mimeType].icon
|
||||
}
|
||||
if (fileName && fileName.includes('.')) {
|
||||
return 'mdi-file-outline'
|
||||
}
|
||||
return 'mdi-file-question-outline'
|
||||
}
|
||||
|
||||
function getColor(mimeType: string | undefined, fileName: string | undefined) {
|
||||
if (mimeType === undefined) {
|
||||
return 'grey-5'
|
||||
}
|
||||
if (mimeType === undefined) return 'grey-5'
|
||||
|
||||
const extension = mime.getExtension(mimeType)
|
||||
|
||||
if (extension) return mimeFileMapping[mimeType].color
|
||||
if (fileName && fileName.includes('.')) return 'blue-11'
|
||||
|
||||
const extFomMime = mime.getExtension(mimeType)
|
||||
if (extFomMime) {
|
||||
return mimeFileMapping[mimeType].color
|
||||
}
|
||||
if (fileName && fileName.includes('.')) {
|
||||
return 'blue-11'
|
||||
}
|
||||
return 'grey-5'
|
||||
}
|
||||
|
||||
function getIconSize(s: string) {
|
||||
type SizeMapping = {
|
||||
[key: string]: string
|
||||
}
|
||||
const sizeMapping: SizeMapping = {
|
||||
function getIconSize(size: string) {
|
||||
const sizeMapping = {
|
||||
preview: '6em',
|
||||
list: '2em',
|
||||
}
|
||||
return sizeMapping[s]
|
||||
return sizeMapping[size as keyof typeof sizeMapping]
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue