From cc2d501d24b5e24c916abe12cbb47fcd6d2b5f89 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Fri, 28 Feb 2025 23:27:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E6=83=85=E6=89=93?= =?UTF-8?q?=E5=8C=85=E5=90=8E=E5=8F=AF=E8=83=BD=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/common/emotion.js | 18 ++++++++---------- .../chat-message-item/chat-message-item.vue | 7 +++++-- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/im-uniapp/common/emotion.js b/im-uniapp/common/emotion.js index cdacb8a..a4d9140 100644 --- a/im-uniapp/common/emotion.js +++ b/im-uniapp/common/emotion.js @@ -6,9 +6,14 @@ const emoTextList = ['憨笑', '媚眼', '开心', '坏笑', '可怜', '爱心', "摇头", "偷瞄", "庆祝", "疾跑", "打滚", "惊吓", "起跳" ]; +const regex = /\#[\u4E00-\u9FA5]{1,3}\;/gi; + +let containEmoji = (content) => { + return regex.test(content) +} let transform = (content, extClass) => { - return content.replace(/\#[\u4E00-\u9FA5]{1,3}\;/gi, (emoText)=>{ + return content.replace(regex, (emoText)=>{ // 将匹配结果替换表情图片 let word = emoText.replace(/\#|\;/gi, ''); let idx = emoTextList.indexOf(word); @@ -21,21 +26,14 @@ let transform = (content, extClass) => { }); } - - let textToPath = (emoText) => { let word = emoText.replace(/\#|\;/gi, ''); let idx = emoTextList.indexOf(word); - let baseUrl = "/" - // #ifdef H5 - baseUrl = window.location.pathname; - // #endif - return `${baseUrl}static/emoji/${idx}.gif`; + return `/static/emoji/${idx}.gif`; } - - export default { + containEmoji, emoTextList, transform, textToPath diff --git a/im-uniapp/components/chat-message-item/chat-message-item.vue b/im-uniapp/components/chat-message-item/chat-message-item.vue index 48632f4..ae6f0c2 100644 --- a/im-uniapp/components/chat-message-item/chat-message-item.vue +++ b/im-uniapp/components/chat-message-item/chat-message-item.vue @@ -17,8 +17,11 @@ - - + + + +