Commit 6476e76f by Sixong.Zhu

调整缩约图

parent de39e602
import { MessageType } from "@/customer-service/model";
import { CardMessage } from '@/customer-service/model/card';
import { CardMessage } from "@/customer-service/model/card";
import Chat from "@/customer-service/xim";
const fsImg = /(fs(.*))/;
const mapping = new Map<MessageType, string>([
[MessageType.Image, '图片'],
[MessageType.Video, '视频'],
[MessageType.Voice, '语音'],
[MessageType.File, '文件'],
[MessageType.Withdraw, '撤回了一条消息'],
[MessageType.MyPurchasePlan, '我的采购计划'],
[MessageType.MyWelfare, '我的福利'],
[MessageType.QuestionAnswer, '问答'],
[MessageType.Pay, '付款通知'],
[MessageType.PayV1, '付款通知'],
[MessageType.Refund, '退款通知'],
[MessageType.RefundV1, '退款通知'],
[MessageType.Notify, '通知'],
])
[MessageType.Image, "图片"],
[MessageType.Video, "视频"],
[MessageType.Voice, "语音"],
[MessageType.File, "文件"],
[MessageType.Withdraw, "撤回了一条消息"],
[MessageType.MyPurchasePlan, "我的采购计划"],
[MessageType.MyWelfare, "我的福利"],
[MessageType.QuestionAnswer, "问答"],
[MessageType.Pay, "付款通知"],
[MessageType.PayV1, "付款通知"],
[MessageType.Refund, "退款通知"],
[MessageType.RefundV1, "退款通知"],
[MessageType.Notify, "通知"],
]);
export function parserMessage(type: MessageType, rawMsg: string) {
try {
......@@ -35,15 +38,28 @@ export function parserMessage(type: MessageType, rawMsg: string) {
if (type === MessageType.Card) {
const p = JSON.parse(rawMsg) as CardMessage;
if (p && p.title) {
return p.title || '通知';
return p.title || "通知";
}
}
const t = mapping.get(type)
const t = mapping.get(type);
if (t) {
return `[${t}]`;
}
return `[系统自动回复]`;
} catch {
return ""
return "";
}
}
export function rebuildImage(url: string) {
if (url) {
const sdk = Chat.getSdk();
const s = sdk.mediaController.buildThumbnail;
if (fsImg.test(url)) {
const m = fsImg.exec(url);
return sdk.global.baseUrl + s(m[0], 300);
}
return url;
}
return "";
}
......@@ -22,9 +22,7 @@
import BaseMessage from "./index";
import FileIcon from "./file-icon.vue";
import { UserAgentHelper } from "@/customer-service/third-party/user-agent";
import Chat from "@/customer-service/xim/";
const fsImg = /(fs(.*))/;
import { rebuildImage } from "../controller";
@Component({ components: { FileIcon } })
export default class Index extends BaseMessage {
......@@ -35,16 +33,7 @@
);
private get mini() {
if (this.messageRealUrl) {
const sdk = Chat.getSdk();
const s = sdk.mediaController.buildThumbnail;
if (fsImg.test(this.messageRealUrl)) {
const m = fsImg.exec(this.messageRealUrl);
return sdk.global.baseUrl + s(m[0], 300);
}
return this.messageRealUrl;
}
return "";
return rebuildImage(this.messageRealUrl);
}
private onImageError() {
......
......@@ -21,6 +21,7 @@ import { decodeJwt } from "uniplat-sdk";
import { ChatStatus, ChatStore, ChatStoreState } from "./model";
import { RootStoreState } from "@/store/model";
import { rebuildImage } from "../components/controller";
export const ns = ChatStore.ns;
......@@ -71,7 +72,7 @@ async function preCacheImgs(msgs?: any[]) {
typeof Image !== "undefined"
) {
const preCache = new Image();
preCache.src = url;
preCache.src = rebuildImage(url);
preCache.onload = () => resolve();
setTimeout(resolve, 2000);
} else {
......
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