perf: 聊天内容链接可点击

This commit is contained in:
kuaifan 2022-05-25 22:14:08 +08:00
parent ca860d551e
commit f9c01f0a7d

View File

@ -211,8 +211,17 @@ export default {
text = text.trim().replace(/(\n\x20*){3,}/g, "\n\n");
text = text.replace(/\{\{RemoteURL\}\}/g, $A.apiUrl('../'))
text = text.replace(/<p><\/p>/g, '<p><br/></p>')
// text = text.replace(/(https*:\/\/)((\w|=|\?|\.|\/|&|-|:|\+|%|;)+)/g, "<a href=\"$1$2\" target=\"_blank\">$1$2</a>");
text = text.replace(this.atUserReg, `<span class="mention me" data-id="${this.userId}">`)
//
if (/https*:\/\//.test(text)) {
text = text.split(/(<[^>]*>)/g).map(string => {
if (string && !/<[^>]*>/.test(string)) {
string = string.replace(/(https*:\/\/)((\w|=|\?|\.|\/|&|-|:|\+|%|;)+)/g, "<a href=\"$1$2\" target=\"_blank\">$1$2</a>")
}
return string;
}).join("")
}
//
const array = text.match(/<img\s+[^>]*?>/g);
if (array) {
const widthReg = new RegExp("width=\"(\\d+)\"")