perf: 优化消息描述

This commit is contained in:
kuaifan 2024-06-04 19:50:12 +08:00
parent a834481d32
commit ff872c7dce
2 changed files with 38 additions and 14 deletions

View File

@ -554,31 +554,53 @@ class WebSocketDialogMsg extends AbstractModel
}
switch ($data['type']) {
case 'text':
case 'word-chain':
case 'vote':
return $this->previewTextMsg($data['msg']['text'], $preserveHtml);
case 'vote':
$action = Doo::translate("投票");
return "[{$action}] {$this->previewTextMsg($data['msg']['text'], $preserveHtml)}";
case 'word-chain':
$action = Doo::translate("接龙");
return "[{$action}] {$this->previewTextMsg($data['msg']['text'], $preserveHtml)}";
case 'record':
return "[语音]";
$action = Doo::translate("语音");
return "[{$action}]";
case 'meeting':
return "[会议] ${$data['msg']['name']}";
$action = Doo::translate("会议");
return "[{$action}] ${$data['msg']['name']}";
case 'file':
if ($data['msg']['type'] == 'img') {
return "[图片]";
$action = Doo::translate("图片");
return "[{$action}]";
} elseif ($data['msg']['ext'] == 'mp4') {
$action = Doo::translate("视频");
return "[{$action}]";
}
return "[文件] {$data['msg']['name']}";
$action = Doo::translate("文件");
return "[{$action}] {$data['msg']['name']}";
case 'tag':
$action = $data['msg']['action'] === 'remove' ? '取消标注' : '标注';
$action = Doo::translate($data['msg']['action'] === 'remove' ? '取消标注' : '标注');
return "[{$action}] {$this->previewMsg(false, $data['msg']['data'])}";
case 'top':
$action = $data['msg']['action'] === 'remove' ? '取消置顶' : '置顶';
$action = Doo::translate($data['msg']['action'] === 'remove' ? '取消置顶' : '置顶');
return "[{$action}] {$this->previewMsg(false, $data['msg']['data'])}";
case 'todo':
$action = $data['msg']['action'] === 'remove' ? '取消待办' : ($data['msg']['action'] === 'done' ? '完成' : '设待办');
$action = Doo::translate($data['msg']['action'] === 'remove' ? '取消待办' : ($data['msg']['action'] === 'done' ? '完成' : '设待办'));
return "[{$action}] {$this->previewMsg(false, $data['msg']['data'])}";
case 'notice':
return $data['msg']['notice'];
default:
return "[未知的消息]";
$action = Doo::translate("未知的消息");
return "[{$action}]";
}
}

View File

@ -854,10 +854,10 @@ import {MarkdownPreview} from "../store/markdown";
switch (data.type) {
case 'text':
return $A.getMsgTextPreview(data.msg.type === 'md' ? MarkdownPreview(data.msg.text) : data.msg.text, imgClassName)
case 'word-chain':
return `[${$A.L('接龙')}]` + $A.getMsgTextPreview(data.msg.text, imgClassName)
case 'vote':
return `[${$A.L('投票')}]` + $A.getMsgTextPreview(data.msg.text, imgClassName)
case 'word-chain':
return `[${$A.L('接龙')}]` + $A.getMsgTextPreview(data.msg.text, imgClassName)
case 'record':
return `[${$A.L('语音')}]`
case 'meeting':
@ -865,14 +865,16 @@ import {MarkdownPreview} from "../store/markdown";
case 'file':
if (data.msg.type == 'img') {
if (imgClassName) {
// 缩略图,主要用于回复消息预览
const width = parseInt(data.msg.width),
height = parseInt(data.msg.height),
maxSize = 40;
const scale = $A.scaleToScale(width, height, maxSize, maxSize);
return `<img class="${imgClassName}" style="width:${scale.width}px;height:${scale.height}px" src="${data.msg.thumb}">`
} else {
return `[${$A.L('图片')}]`
}
return `[${$A.L('图片')}]`
} else if (data.msg.ext == 'mp4') {
return `[${$A.L('视频')}]`
}
return `[${$A.L('文件')}] ${data.msg.name}`
case 'tag':