mirror of
https://github.com/keven1024/015.git
synced 2026-05-26 07:08:02 +00:00
30 lines
602 B
Vue
30 lines
602 B
Vue
<script setup lang="ts">
|
|
import { isHeic, heicTo } from 'heic-to'
|
|
|
|
const props = defineProps<{
|
|
file: File
|
|
}>()
|
|
|
|
const { state: imageUrl } = useAsyncState(async () => {
|
|
let blob: Blob = props?.file
|
|
if (await isHeic(props?.file)) {
|
|
blob = await heicTo({
|
|
blob: props?.file,
|
|
type: 'image/jpeg',
|
|
quality: 1,
|
|
})
|
|
}
|
|
return URL.createObjectURL(blob)
|
|
}, null)
|
|
|
|
onUnmounted(() => {
|
|
if (imageUrl.value) {
|
|
URL.revokeObjectURL(imageUrl.value)
|
|
}
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<img v-if="!!imageUrl" :src="imageUrl" />
|
|
</template>
|