Commit 6e9fbd6b by Sixong.Zhu

调整消息机制,调整图片显示机制

parent 6711c5df
...@@ -4,20 +4,20 @@ ...@@ -4,20 +4,20 @@
:before-close="close" :before-close="close"
:visible="value" :visible="value"
:show-close="false" :show-close="false"
custom-class="transparent" custom-class="transparent flex"
width="90%" width="90%"
top="60px"
> >
<div class="d-flex flex-column"> <div class="d-flex flex-column">
<div class="d-flex justify-content-center align-items-start"> <div class="d-flex justify-content-center align-items-start">
<img v-if="file" :src="file.url" /> <img v-if="file" :src="file.url" :style="imgStyle" />
<i class="el-icon-close" @click="close"></i> <i class="el-icon-close" @click="close"></i>
</div>
<div class="d-flex justify-content-center actions">
<a <a
class="d-flex align-items-center justify-content-center" class="d-flex align-items-center justify-content-center"
:href="file.url" :href="file.url"
:download="getAttachment" :download="getAttachment"
target="_blank"
> >
<i class="el-icon-download"></i> <i class="el-icon-download"></i>
</a> </a>
...@@ -37,6 +37,13 @@ ...@@ -37,6 +37,13 @@
@Prop() @Prop()
private file!: { name: string; url: string }; private file!: { name: string; url: string };
private get imgStyle() {
return {
"max-width": `${document.body.scrollWidth * 0.8}px`,
"max-height": `${document.body.scrollHeight * 0.8}px`,
};
}
private close() { private close() {
this.$emit("update", false); this.$emit("update", false);
} }
...@@ -70,25 +77,19 @@ ...@@ -70,25 +77,19 @@
} }
} }
.actions {
margin: 15px 0;
a { a {
width: 50px; padding: 10px;
height: 50px;
background-color: #7a7b7d; background-color: #7a7b7d;
color: #fff;
border-radius: 50%; border-radius: 50%;
cursor: pointer; position: absolute;
left: 50%;
bottom: -65px;
margin-left: -50px;
i { i {
color: #fff; color: #fff;
font-size: 30px; font-size: 30px;
} cursor: pointer;
& + span {
margin-left: 15px;
}
} }
} }
</style> </style>
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
@click="open" @click="open"
> >
<img <img
v-if="messageRealUrl" v-if="mini"
:src="messageRealUrl" :src="mini"
:title="messageBody.msg.name" :title="messageBody.msg.name"
:alt="messageBody.msg.name" :alt="messageBody.msg.name"
@error="onImageError" @error="onImageError"
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
import BaseMessage from "./index"; import BaseMessage from "./index";
import FileIcon from "./file-icon.vue"; import FileIcon from "./file-icon.vue";
import { UserAgentHelper } from "@/customer-service/third-party/user-agent"; import { UserAgentHelper } from "@/customer-service/third-party/user-agent";
import Chat from "@/customer-service/xim/";
@Component({ components: { FileIcon } }) @Component({ components: { FileIcon } })
export default class Index extends BaseMessage { export default class Index extends BaseMessage {
...@@ -31,6 +32,21 @@ ...@@ -31,6 +32,21 @@
window.navigator.userAgent window.navigator.userAgent
); );
private get mini() {
if (this.messageRealUrl) {
const sdk = Chat.getSdk();
const s = sdk.mediaController.buildThumbnail;
if (this.messageRealUrl.startsWith("http")) {
return (
sdk.global.baseUrl +
s(this.messageRealUrl.replace(sdk.global.baseUrl, ""), 300)
);
}
return s(this.messageRealUrl, 300);
}
return "";
}
private onImageError() { private onImageError() {
this.fileFailed2Load = true; this.fileFailed2Load = true;
this.messageRealUrl = ""; this.messageRealUrl = "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment