From 4561efc3cea8d4d26d5356a849f06781af5877f4 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sun, 10 Jul 2022 21:16:46 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E5=8E=BB=E9=99=A4=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E9=87=8C=E7=9A=84 ?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/WebSocketDialogMsg.php | 8 ++++---- resources/assets/js/functions/web.js | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Models/WebSocketDialogMsg.php b/app/Models/WebSocketDialogMsg.php index 05a099420..0cbb4769f 100644 --- a/app/Models/WebSocketDialogMsg.php +++ b/app/Models/WebSocketDialogMsg.php @@ -502,11 +502,11 @@ class WebSocketDialogMsg extends AbstractModel $text = preg_replace("/]*?alt=\"(\S+)\"[^>]*?>/", "[$1]", $text); $text = preg_replace("/]*?>/", "[表情]", $text); $text = preg_replace("/]*?>/", "[图片]", $text); - if ($preserveHtml) { - return $text; - } else { - return strip_tags($text); + if (!$preserveHtml) { + $text = strip_tags($text); + $text = str_replace(" ", " ", $text); } + return $text; } /** diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js index 9f784c484..25eaf4ab3 100755 --- a/resources/assets/js/functions/web.js +++ b/resources/assets/js/functions/web.js @@ -368,6 +368,7 @@ text = text.replace(/]*?alt="(\S+)"[^>]*?>/g, "[$1]") text = text.replace(/]*?>/g, `[${$A.L('表情')}]`) text = text.replace(/]*?>/g, `[${$A.L('图片')}]`) + text = text.replace(/ /g," ") return text.replace(/<[^>]+>/g,"") },