perf: 优化文本信息复制

This commit is contained in:
kuaifan 2025-02-25 17:47:46 +08:00
parent 94932c7486
commit e32a3887cd

View File

@ -3134,6 +3134,14 @@ export default {
value: '', value: '',
}) })
} }
if (msgData.msg.type === 'md') {
this.operateCopys.push({
type: 'md',
icon: '',
label: '复制原文',
value: '',
})
}
} }
this.$nextTick(() => { this.$nextTick(() => {
const rect = el.getBoundingClientRect(); const rect = el.getBoundingClientRect();
@ -3563,12 +3571,19 @@ export default {
case 'text': case 'text':
const copyEl = $A(this.$refs.scroller.$el).find(`[data-id="${this.operateItem.id}"]`).find('.dialog-content') const copyEl = $A(this.$refs.scroller.$el).find(`[data-id="${this.operateItem.id}"]`).find('.dialog-content')
if (copyEl.length > 0) { if (copyEl.length > 0) {
const text = copyEl[0].innerText.replace(/\n\n/g, "\n").replace(/(^\s*)|(\s*$)/g, "") let copyText = copyEl[0].innerText;
this.copyText(text) if ($A.getObject(this.operateItem.msg, 'type') !== 'md') {
copyText = copyText.replace(/\n\n/g, "\n").replace(/(^\s*)|(\s*$)/g, "")
}
this.copyText(copyText)
} else { } else {
$A.messageWarning('不可复制的内容'); $A.messageWarning('不可复制的内容');
} }
break; break;
case 'md':
this.copyText(this.operateItem.msg.text)
break;
} }
}, },