mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
perf: 优化菜单显示、选择复制
This commit is contained in:
parent
3d783c59c2
commit
f49f73409c
@ -610,6 +610,7 @@ export default {
|
|||||||
navStyle: {},
|
navStyle: {},
|
||||||
|
|
||||||
operateVisible: false,
|
operateVisible: false,
|
||||||
|
operatePreventScroll: 0,
|
||||||
operateCopys: [],
|
operateCopys: [],
|
||||||
operateStyles: {},
|
operateStyles: {},
|
||||||
operateItem: {},
|
operateItem: {},
|
||||||
@ -1379,7 +1380,11 @@ export default {
|
|||||||
item.msg.text = data.text
|
item.msg.text = data.text
|
||||||
}
|
}
|
||||||
if (tail <= 55) {
|
if (tail <= 55) {
|
||||||
this.onToBottom()
|
this.operatePreventScroll++
|
||||||
|
this.$refs.scroller.scrollToBottom();
|
||||||
|
setTimeout(_ => {
|
||||||
|
this.operatePreventScroll--
|
||||||
|
}, 50)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2171,7 +2176,9 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onScroll(event) {
|
onScroll(event) {
|
||||||
this.operateVisible = false;
|
if (this.operatePreventScroll === 0) {
|
||||||
|
this.operateVisible = false;
|
||||||
|
}
|
||||||
//
|
//
|
||||||
const {offset, tail} = this.scrollInfo();
|
const {offset, tail} = this.scrollInfo();
|
||||||
this.scrollOffset = offset;
|
this.scrollOffset = offset;
|
||||||
@ -2294,11 +2301,24 @@ export default {
|
|||||||
value: $A.thumbRestore(event.target.currentSrc),
|
value: $A.thumbRestore(event.target.currentSrc),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
const selectText = this.getSelectedTextInElement(el)
|
||||||
|
if (selectText.length > 0) {
|
||||||
|
this.operateCopys.push({
|
||||||
|
type: 'selected',
|
||||||
|
icon: '',
|
||||||
|
label: '复制选择',
|
||||||
|
value: selectText,
|
||||||
|
})
|
||||||
|
}
|
||||||
if (msgData.msg.text.replace(/<[^>]+>/g,"").length > 0) {
|
if (msgData.msg.text.replace(/<[^>]+>/g,"").length > 0) {
|
||||||
|
let label = this.operateCopys.length > 0 ? '复制文本' : '复制'
|
||||||
|
if (selectText.length > 0) {
|
||||||
|
label = '复制全部'
|
||||||
|
}
|
||||||
this.operateCopys.push({
|
this.operateCopys.push({
|
||||||
type: 'text',
|
type: 'text',
|
||||||
icon: '',
|
icon: '',
|
||||||
label: this.operateCopys.length > 0 ? '复制文本' : '复制',
|
label,
|
||||||
value: '',
|
value: '',
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -2440,6 +2460,10 @@ export default {
|
|||||||
this.$copyText(value).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败'))
|
this.$copyText(value).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败'))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'selected':
|
||||||
|
this.$copyText(value).then(_ => $A.messageSuccess('复制成功')).catch(_ => $A.messageError('复制失败'))
|
||||||
|
break;
|
||||||
|
|
||||||
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) {
|
||||||
@ -2921,6 +2945,20 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getSelectedTextInElement(element) {
|
||||||
|
let selectedText = "";
|
||||||
|
if (window.getSelection) {
|
||||||
|
let selection = window.getSelection();
|
||||||
|
if (selection.rangeCount > 0) {
|
||||||
|
const range = selection.getRangeAt(0);
|
||||||
|
if (element.contains(range.commonAncestorContainer)) {
|
||||||
|
selectedText = range.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return selectedText;
|
||||||
|
},
|
||||||
|
|
||||||
onViewAvatar(e) {
|
onViewAvatar(e) {
|
||||||
let src = null
|
let src = null
|
||||||
if (e.target.tagName === "IMG") {
|
if (e.target.tagName === "IMG") {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user