From d17759994d85394604a43e744dd0814f7f07b777 Mon Sep 17 00:00:00 2001 From: DCloud_JSON Date: Mon, 24 Jun 2024 15:17:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20=E8=A7=A3=E5=86=B3msg=20no?= =?UTF-8?q?te=E5=AD=98=E5=9C=A8 =20 =20&ensp=20=E7=AC=A6?= =?UTF-8?q?=E5=8F=B7=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sdk/utils/index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sdk/utils/index.js b/sdk/utils/index.js index 63971ec..6b3dbb6 100644 --- a/sdk/utils/index.js +++ b/sdk/utils/index.js @@ -130,8 +130,6 @@ export default { note = "消息已被删除" } else if (type === 'text') { note = msg.body.toString() - note = note.replace(/(\r\n|\n|\r)/gm, ""); - note = note.slice(0, 80) } else if (type === 'userinfo-card') { note = `[${msg.body.name} 的名片]` } else { @@ -192,6 +190,12 @@ export default { } } } + // 去掉换行符 + note = note.replace(/(\r\n|\n|\r)/gm, ""); + // 改      等空格为普通空格 + note = note.replace(/ | | /g, ' ') + // 截取80个字符 + note = note.slice(0, 80).trim() return note }, // 节流执行函数,用于控制频繁触发的事件。 -- GitLab