2023-05-31 20:43:27 +08:00
|
|
|
<script setup lang="ts">
|
|
|
|
|
|
|
|
|
|
|
|
import { useImage } from '@vueuse/core'
|
|
|
|
|
|
|
|
const props = $defineProps<{
|
|
|
|
src:string
|
2023-06-01 01:03:02 +08:00
|
|
|
errSrc?:string
|
2023-05-31 20:43:27 +08:00
|
|
|
}>()
|
2023-06-01 01:03:02 +08:00
|
|
|
// const isGIF =
|
2023-05-31 20:43:27 +08:00
|
|
|
const avatarUrl = props.src
|
|
|
|
const { isLoading,error } = useImage({ src: avatarUrl })
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div v-if="isLoading" class="animate-pulse w-full h-full bg-slate/10 flex items-center justify-center">
|
2023-06-01 01:03:02 +08:00
|
|
|
<div class="i-line-md-loading-twotone-loop"/>
|
2023-05-31 20:43:27 +08:00
|
|
|
</div>
|
2023-06-01 01:03:02 +08:00
|
|
|
<!-- <div v-if="error" class="animate-pulse w-full h-full bg-rose/10 flex items-center justify-center">
|
2023-05-31 20:43:27 +08:00
|
|
|
Error
|
2023-06-01 01:03:02 +08:00
|
|
|
</div> -->
|
|
|
|
<img v-else :src="error?errSrc:avatarUrl" style="object-fit: cover;">
|
|
|
|
|
2023-05-31 20:43:27 +08:00
|
|
|
</template>
|
|
|
|
|