Add file image as fallback preview
This commit is contained in:
parent
658936a070
commit
ef8bb5aca9
@ -29,6 +29,7 @@ import {
|
|||||||
faExclamation,
|
faExclamation,
|
||||||
faEye,
|
faEye,
|
||||||
faEyeSlash,
|
faEyeSlash,
|
||||||
|
faFileImage,
|
||||||
faFillDrip,
|
faFillDrip,
|
||||||
faFilter,
|
faFilter,
|
||||||
faForward,
|
faForward,
|
||||||
@ -81,7 +82,6 @@ import {
|
|||||||
faCheckSquare,
|
faCheckSquare,
|
||||||
faClock,
|
faClock,
|
||||||
faComments,
|
faComments,
|
||||||
faFileImage,
|
|
||||||
faSave,
|
faSave,
|
||||||
faSquareCheck,
|
faSquareCheck,
|
||||||
faStar,
|
faStar,
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
>
|
>
|
||||||
<div class="preview-column">
|
<div class="preview-column">
|
||||||
<FilePreview
|
<FilePreview
|
||||||
v-if="canPreview(a)"
|
|
||||||
class="attachment-preview"
|
class="attachment-preview"
|
||||||
:model-value="a"
|
:model-value="a"
|
||||||
/>
|
/>
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
<template>
|
<template>
|
||||||
<img
|
<img
|
||||||
|
v-if="blobUrl"
|
||||||
:src="blobUrl"
|
:src="blobUrl"
|
||||||
alt="Attachment preview"
|
alt="Attachment preview"
|
||||||
>
|
>
|
||||||
|
<icon
|
||||||
|
v-else
|
||||||
|
size="6x"
|
||||||
|
icon="file-image"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import {type PropType, ref, shallowReactive, watchEffect} from 'vue'
|
import {type PropType, ref, shallowReactive, watchEffect} from 'vue'
|
||||||
import AttachmentService from '@/services/attachment'
|
import AttachmentService from '@/services/attachment'
|
||||||
import type { IAttachment } from '@/modelTypes/IAttachment'
|
import type {IAttachment} from '@/modelTypes/IAttachment'
|
||||||
|
import {SUPPORTED_IMAGE_SUFFIX} from '@/models/attachment'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
@ -21,10 +28,14 @@ const attachmentService = shallowReactive(new AttachmentService())
|
|||||||
const blobUrl = ref<string | undefined>(undefined)
|
const blobUrl = ref<string | undefined>(undefined)
|
||||||
|
|
||||||
watchEffect(async () => {
|
watchEffect(async () => {
|
||||||
if (props.modelValue) {
|
if (props.modelValue && canPreview(props.modelValue)) {
|
||||||
blobUrl.value = await attachmentService.getBlobUrl(props.modelValue)
|
blobUrl.value = await attachmentService.getBlobUrl(props.modelValue)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function canPreview(attachment: IAttachment): boolean {
|
||||||
|
return SUPPORTED_IMAGE_SUFFIX.some((suffix) => attachment.file.name.endsWith(suffix))
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user