diff --git a/im-uniapp/common/emotion.js b/im-uniapp/common/emotion.js index 7e301e0..cdacb8a 100644 --- a/im-uniapp/common/emotion.js +++ b/im-uniapp/common/emotion.js @@ -26,7 +26,11 @@ let transform = (content, extClass) => { let textToPath = (emoText) => { let word = emoText.replace(/\#|\;/gi, ''); let idx = emoTextList.indexOf(word); - return `/static/emoji/${idx}.gif`; + let baseUrl = "/" + // #ifdef H5 + baseUrl = window.location.pathname; + // #endif + return `${baseUrl}static/emoji/${idx}.gif`; } diff --git a/im-uniapp/common/url.js b/im-uniapp/common/url.js new file mode 100644 index 0000000..ff04275 --- /dev/null +++ b/im-uniapp/common/url.js @@ -0,0 +1,15 @@ +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) => { + // 如果URL不以http(s)://开头,则添加http://前缀 + if (!url.startsWith("http")) { + url = "http://" + url; + } + return `${url}`; + }); +} + +export default { + replaceURLWithHTMLLinks +} \ No newline at end of file diff --git a/im-uniapp/components/bar/arrow-bar.vue b/im-uniapp/components/bar/arrow-bar.vue index 97e6dfb..6ecf189 100644 --- a/im-uniapp/components/bar/arrow-bar.vue +++ b/im-uniapp/components/bar/arrow-bar.vue @@ -1,5 +1,6 @@