chat-app/src/components/talk/message/ImageMessage.vue
caiyx 1213ad9b98
Some checks failed
Check / lint (push) Has been cancelled
Check / typecheck (push) Has been cancelled
Check / build (build, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build, 18.x, windows-latest) (push) Has been cancelled
Check / build (build:app, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build:app, 18.x, windows-latest) (push) Has been cancelled
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Has been cancelled
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Has been cancelled
fix
2024-12-20 16:59:58 +08:00

98 lines
1.9 KiB
Vue

<script lang="ts" setup>
import { getImageInfo } from '@/utils/functions'
import { computed } from 'vue'
const props = defineProps<{
extra: any
data: any
maxWidth?: Boolean
}>()
const img = computed(() => {
// console.log(props.extra);
let info = {
width: 0,
height: 0
}
if (props.extra.url.includes('blob:http://')) {
info = {
width: props.extra.width,
height: props.extra.height
}
}else {
info = getImageInfo(props.extra.url)
}
if (info.width == 0 || info.height == 0) {
return {
width: 450,
height: 298
}
}
if(info.width<300){
return {
width: 300,
height: info.height / (info.width / 300)
}
}
if (info.width < 350) {
return {
width: info.width,
height: info.height
}
}
return {
width: 350,
height: info.height / (info.width / 350)
}
})
</script>
<template>
<section
class="im-message-image"
:class="{
left: data.float === 'left',
right: data.float === 'right'
}"
>
<div class="image-container">
<tm-image preview :width="img.width" :height="img.height" :src="extra.url" />
<wd-circle custom-class="circleProgress" v-if="props.data.uploadCurrent && props.data.uploadCurrent<100" v-model="props.data.uploadCurrent" color="#ffffff" layer-color="#E3E3E3"></wd-circle>
</div>
</section>
</template>
<style lang="less" scoped>
.im-message-image {
overflow: hidden;
padding: 20rpx 18rpx;
border-radius: 0;
background-color: #fff;
min-width: 40rpx;
min-height: 40rpx;
max-width: 532rpx;
&.left {
background-color: #fff;
border-radius: 0 16rpx 16rpx 16rpx;
}
&.right {
background-color: #46299D;
border-radius: 16rpx 0 16rpx 16rpx;
}
}
.image-container {
position: relative;
.circleProgress {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1;
}
}
</style>