优化复制消息

This commit is contained in:
kuaifan 2022-07-15 14:21:01 +08:00
parent b20506cfa0
commit 1a1c03b355
2 changed files with 22 additions and 9 deletions

View File

@ -11,10 +11,10 @@ import App from './App.vue'
import routes from './routes'
import VueRouter from 'vue-router'
import VueClipboard from 'vue-clipboard2'
import ViewUI from 'view-design-hi';
import ViewUI from 'view-design-hi'
import Language from './language/index'
import store from './store/index'
import mixin from "./store/mixin";
import mixin from "./store/mixin"
Vue.use(Vuex);
Vue.use(ViewUI, {
@ -22,7 +22,11 @@ Vue.use(ViewUI, {
checkEscClose: true
}
});
Vue.use(VueClipboard);
Vue.use(VueClipboard, {
config: {
autoSetContainer: true
}
});
Vue.use(VueRouter);
Vue.use(Language);

View File

@ -1597,12 +1597,7 @@ export default {
break;
case "copy":
if (this.operateHasText) {
const text = this.operateItem.msg.text.replace(/<[^>]+>/g, "")
this.$copyText(text).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败'));
} else {
$A.messageWarning('不可复制的内容');
}
this.onCopy()
break;
case "forward":
@ -1661,6 +1656,20 @@ export default {
}
},
onCopy() {
if (this.operateHasText) {
try {
const copyEl = $A(this.$refs.scroller.$el).find(`[data-id="${this.operateItem.id}"]`).find('.dialog-content')
if (copyEl.length > 0) {
const text = copyEl[0].innerText.replace(/\n\n/g, "\n")
this.$copyText(text).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败'));
return
}
} catch (e) {}
}
$A.messageWarning('不可复制的内容');
},
onCancelReply() {
if (this.replyActiveUpdate) {
this.replyActiveUpdate = false