From b373be7b0d7a050d02e8988d14f33612cae9d44b Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Thu, 3 Jul 2025 16:02:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E6=8D=A2=E8=A1=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/common/url.js | 14 +++++++++++--- .../chat-message-item/chat-message-item.vue | 14 +++++++------- im-uniapp/pages/chat/chat-box.vue | 6 ++++-- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/im-uniapp/common/url.js b/im-uniapp/common/url.js index ff04275..c95d834 100644 --- a/im-uniapp/common/url.js +++ b/im-uniapp/common/url.js @@ -1,7 +1,14 @@ + +// 使用正则表达式匹配更广泛的URL格式(此正则由deepseek生成) +const regex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]|\bwww\.[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; + +let containUrl = (content) => { + return regex.test(content) +} + + let replaceURLWithHTMLLinks = (content, color) => { - // 使用正则表达式匹配更广泛的URL格式(此正则由deepseek生成) - const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]|\bwww\.[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; - return content.replace(urlRegex, (url) => { + return content.replace(regex, (url) => { // 如果URL不以http(s)://开头,则添加http://前缀 if (!url.startsWith("http")) { url = "http://" + url; @@ -11,5 +18,6 @@ let replaceURLWithHTMLLinks = (content, color) => { } export default { + containUrl, replaceURLWithHTMLLinks } \ No newline at end of file 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 aa7441c..060ac0a 100644 --- a/im-uniapp/components/chat-message-item/chat-message-item.vue +++ b/im-uniapp/components/chat-message-item/chat-message-item.vue @@ -16,11 +16,11 @@ - - - - + + + + @@ -39,8 +39,8 @@ - + {{ fileSize }} diff --git a/im-uniapp/pages/chat/chat-box.vue b/im-uniapp/pages/chat/chat-box.vue index d2bd260..958fa3f 100644 --- a/im-uniapp/pages/chat/chat-box.vue +++ b/im-uniapp/pages/chat/chat-box.vue @@ -288,7 +288,9 @@ export default { sendText += op.insert ) }) - if (!sendText.trim() && this.atUserIds.length == 0) { + // 去除最后的换行符 + sendText = sendText.trim(); + if (!sendText && this.atUserIds.length == 0) { return uni.showToast({ title: "不能发送空白信息", icon: "none" @@ -610,7 +612,7 @@ export default { query.select('.chat-wrap').boundingClientRect(); query.exec(data => { this.scrollTop = data[0].height - scrollViewHeight; - if(this.scrollTop < 10){ + if (this.scrollTop < 10) { // 未渲染完成,重试一次 this.holdingScrollBar(); }