feat: support blurhash

This commit is contained in:
Anthony Fu 2022-11-21 21:21:53 +08:00
parent af2c6d622b
commit 757a93c2a2
8 changed files with 102 additions and 25 deletions

View file

@ -4,21 +4,33 @@ import type { Attachment } from 'masto'
const { attachment } = defineProps<{
attachment: Attachment
}>()
const aspectRatio = computed(() => {
if (attachment.meta?.original?.aspect)
return attachment.meta.original.aspect
if (attachment.meta?.small?.aspect)
return attachment.meta.small.aspect
return undefined
})
</script>
<template>
<template v-if="attachment.type === 'image'">
<img
<template v-if="attachment.type === 'image' || attachment.type === 'gifv'">
<CommonBlurhash
:blurhash="attachment.blurhash"
class="status-attachment-image"
:src="attachment.previewUrl!"
:alt="attachment.description!"
border="~ border"
:style="{
aspectRatio,
}"
object-cover rounded-lg
>
/>
</template>
<template v-else>
<div>
TODO: {{ attachment }}
</div>
TODO:
<pre>{{ attachment }}
</pre>
</template>
</template>