mirror of https://github.com/nocodb/nocodb
Yoones Khoshghadam
1 week ago
3 changed files with 53 additions and 13 deletions
@ -0,0 +1,13 @@
|
||||
<script setup lang="ts"> |
||||
|
||||
const props = defineProps<{ |
||||
item: any |
||||
}>() |
||||
|
||||
const icon = useAttachmentIcon(() => props.item.title, props.item.mimetype) |
||||
|
||||
</script> |
||||
|
||||
<template> |
||||
<GeneralIcon :icon="icon" class="text-white" /> |
||||
</template> |
@ -0,0 +1,38 @@
|
||||
|
||||
export const useAttachmentIcon = (title: MaybeRefOrGetter<string | undefined>, mimetype: MaybeRefOrGetter<string | undefined>) => { |
||||
return computed<keyof typeof iconMap>(() => { |
||||
if (isImage(toValue(title) || '', toValue(mimetype))) { |
||||
return 'image' |
||||
} |
||||
|
||||
if (isPdf(toValue(title) || '', toValue(mimetype))) { |
||||
return 'ncFileTypePdf' |
||||
} |
||||
|
||||
if (isVideo(toValue(title) || '', toValue(mimetype))) { |
||||
return 'ncFileTypeVideo' |
||||
} |
||||
|
||||
if (isAudio(toValue(title) || '', toValue(mimetype))) { |
||||
return 'ncFileTypeAudio' |
||||
} |
||||
|
||||
if (isWord(toValue(title) || '', toValue(mimetype))) { |
||||
return 'ncFileTypeWord' |
||||
} |
||||
|
||||
if (isExcel(toValue(title) || '', toValue(mimetype))) { |
||||
return 'ncFileTypeExcel' |
||||
} |
||||
|
||||
if (isPresentation(toValue(title) || '', toValue(mimetype))) { |
||||
return 'ncFileTypePresentation' |
||||
} |
||||
|
||||
if (isZip(toValue(title) || '', toValue(mimetype))) { |
||||
return 'ncFileTypeZip' |
||||
} |
||||
|
||||
return 'ncFileTypeUnknown' |
||||
}) |
||||
} |
Loading…
Reference in new issue