perf: 优化预览消息

This commit is contained in:
kuaifan 2024-11-03 08:23:41 +08:00
parent 6ed0e14fe0
commit a95504bbf1
2 changed files with 2 additions and 0 deletions

View File

@ -633,6 +633,7 @@ class WebSocketDialogMsg extends AbstractModel
$text = preg_replace("/<img\s+class=\"emoticon\"[^>]*?>/", "[动画表情]", $text);
$text = preg_replace("/<img\s+class=\"browse\"[^>]*?>/", "[图片]", $text);
if (!$preserveHtml) {
$text = str_replace("</p><p>", "</p> <p>", $text);
$text = strip_tags($text);
$text = str_replace(["&nbsp;", "&amp;", "&lt;", "&gt;"], [" ", "&", "<", ">"], $text);
$text = preg_replace("/\s+/", " ", $text);

View File

@ -270,6 +270,7 @@ import {MarkdownPreview} from "../store/markdown";
text = text.replace(/<img\s+class="browse"[^>]*?>/g, `[${$A.L('图片')}]`)
}
text = text
.replace(/<\/p><p>/g, "</p> <p>")
.replace(/<[^>]+>/g, "")
.replace(/&nbsp;/g, " ")
.replace(/&quot;/g, "\"")