no message

This commit is contained in:
kuaifan 2024-01-10 23:08:56 +08:00
parent bea7ba00f0
commit e74aeb9393
2 changed files with 39 additions and 56 deletions

View File

@ -795,6 +795,11 @@ export default {
this.observers = [] this.observers = []
// //
document.removeEventListener('selectionchange', this.onSelectionchange); document.removeEventListener('selectionchange', this.onSelectionchange);
//
const scroller = this.$refs.scroller;
if (scroller) {
scroller.virtual.destroy()
}
}, },
computed: { computed: {
@ -1152,8 +1157,8 @@ export default {
}, },
dialogId: { dialogId: {
handler(dialog_id, old_id) { handler(dialog_id, old_id) {
this.scrollInit()
if (dialog_id) { if (dialog_id) {
this.scrollInit()
this.msgNew = 0 this.msgNew = 0
this.msgType = '' this.msgType = ''
this.unreadOne = 0 this.unreadOne = 0
@ -1198,9 +1203,10 @@ export default {
if (this.autoFocus) { if (this.autoFocus) {
this.inputFocus() this.inputFocus()
} }
//
this.getUserApproveStatus()
} }
this.$store.dispatch('closeDialog', old_id) this.$store.dispatch('closeDialog', old_id)
this.getUserApproveStatus();
}, },
immediate: true immediate: true
}, },
@ -1231,13 +1237,6 @@ export default {
this.observers.push({key: 'scroller', observer: scrollerObserver}) this.observers.push({key: 'scroller', observer: scrollerObserver})
} }
} }
if (this.$refs.footer) {
if (!this.observers.find(({key}) => key === 'footer')) {
const footerObserver = new ResizeObserver(this.onResizeEvent)
footerObserver.observe(this.$refs.footer);
this.observers.push({key: 'footer', observer: footerObserver})
}
}
}) })
}, },
immediate: true immediate: true
@ -1347,7 +1346,7 @@ export default {
} }
// //
if (!this.windowActive || (tail > 55 && oldList.length > 0)) { if (!this.windowActive || (tail > 55 && oldList.length > 0)) {
const lastId = oldList[oldList.length - 1] ? oldList[oldList.length - 1].id : 0 const lastId = oldList[oldList.length - 1]?.id || 0
const tmpList = newList.filter(item => item.id && item.id > lastId && item.userid != this.userId && !item.read_at) const tmpList = newList.filter(item => item.id && item.id > lastId && item.userid != this.userId && !item.read_at)
this.msgNew += tmpList.length this.msgNew += tmpList.length
} else { } else {
@ -1396,7 +1395,6 @@ export default {
this.$refs.footer.style.paddingBottom = `${val}px`; this.$refs.footer.style.paddingBottom = `${val}px`;
requestAnimationFrame(_ => { requestAnimationFrame(_ => {
this.$refs.input.updateTools() this.$refs.input.updateTools()
this.onFooterResize()
}) })
}, },
@ -1601,10 +1599,8 @@ export default {
const {tail: newTail} = this.scrollInfo() const {tail: newTail} = this.scrollInfo()
if (tail <= 10 && newTail != tail) { if (tail <= 10 && newTail != tail) {
this.operatePreventScroll++ this.operatePreventScroll++
this.$refs.scroller.scrollToBottom(); this.$refs.scroller.scrollToBottom()
setTimeout(_ => { setTimeout(_ => this.operatePreventScroll--, 50)
this.operatePreventScroll--
}, 50)
} }
}) })
} }
@ -1755,7 +1751,6 @@ export default {
this.todoViewData = {} this.todoViewData = {}
this.todoViewMid = 0 this.todoViewMid = 0
this.todoViewId = 0 this.todoViewId = 0
this.onFooterResize()
}, },
onPosTodo() { onPosTodo() {
@ -2076,8 +2071,6 @@ export default {
entries.some(({target, contentRect}) => { entries.some(({target, contentRect}) => {
if (target === this.$refs.msgs) { if (target === this.$refs.msgs) {
this.onMsgsResize(contentRect) this.onMsgsResize(contentRect)
} else if (target === this.$refs.footer) {
this.onFooterResize()
} }
}) })
}, },
@ -2097,17 +2090,6 @@ export default {
this.__msgs_height = height; this.__msgs_height = height;
}, },
onFooterResize() {
if (!this.$refs.footer) {
return
}
const footer = this.$refs.footer;
const marginSize = parseInt($A.css(footer, 'marginTop')) + parseInt($A.css(footer, 'marginBottom'))
if (this.$refs.msgs) {
this.$refs.msgs.style.marginBottom = `${footer.getBoundingClientRect().height + marginSize}px`;
}
},
onActive() { onActive() {
this.$emit("on-active"); this.$emit("on-active");
}, },
@ -2117,6 +2099,7 @@ export default {
const scroller = this.$refs.scroller; const scroller = this.$refs.scroller;
if (scroller) { if (scroller) {
scroller.scrollToBottom(); scroller.scrollToBottom();
requestAnimationFrame(_ => scroller.scrollToBottom()) //
} }
}, },
@ -2127,6 +2110,7 @@ export default {
const element = scroller.$el.querySelector(`[data-id="${id}"]`) const element = scroller.$el.querySelector(`[data-id="${id}"]`)
if (!element?.parentNode.parentNode.classList.contains('item-enter')) { if (!element?.parentNode.parentNode.classList.contains('item-enter')) {
scroller.scrollToIndex(index, -80); scroller.scrollToIndex(index, -80);
requestAnimationFrame(_ => scroller.scrollToIndex(index, -80)) //
} }
} }
requestAnimationFrame(_ => this.msgActiveId = id) requestAnimationFrame(_ => this.msgActiveId = id)
@ -2165,12 +2149,11 @@ export default {
scrollInit() { scrollInit() {
const scroller = this.$refs.scroller; const scroller = this.$refs.scroller;
if (scroller) { if (scroller && this.allMsgs.length > 0) {
const scrollEl = scroller.$el scroller.virtual.destroy()
scrollEl.style.visibility = 'hidden' this.allMsgs = []
this.$nextTick(_ => { scroller.scrollToOffset(0)
scrollEl.style.visibility = 'visible' scroller.installVirtual()
})
} }
}, },
@ -2257,12 +2240,12 @@ export default {
}, },
onItemRendered(id, size) { onItemRendered(id, size) {
if (!this.$refs.scroller || !this.$refs.footer) { const scroller = this.$refs.scroller
if (!scroller) {
return return
} }
if (this.renderMsgNum > 0 && this.$refs.scroller.getSizes() >= this.renderMsgNum) { if (this.renderMsgNum > 0 && scroller.getSizes() >= this.renderMsgNum) {
this.renderMsgNum = 0 this.renderMsgNum = 0
this.onFooterResize()
!this.onMarkOffset(true) && this.onToBottom() !this.onMarkOffset(true) && this.onToBottom()
} else if (this.renderMsgSizes.has(id) } else if (this.renderMsgSizes.has(id)
&& size > this.renderMsgSizes.get(id) && size > this.renderMsgSizes.get(id)
@ -2583,20 +2566,24 @@ export default {
} }
const key = this.scrollDirection === 'down' ? 'next_id' : 'prev_id'; const key = this.scrollDirection === 'down' ? 'next_id' : 'prev_id';
for (let i = range.start; i <= range.end; i++) { for (let i = range.start; i <= range.end; i++) {
if (!this.allMsgs[i]) {
continue
}
const rangeValue = this.allMsgs[i][key] const rangeValue = this.allMsgs[i][key]
if (rangeValue) { if (!rangeValue) {
const nearMsg = this.allMsgs[i + (key === 'next_id' ? 1 : -1)] continue
if (nearMsg && nearMsg.id != rangeValue) { }
this.preventMoreLoad = true const nearMsg = this.allMsgs[i + (key === 'next_id' ? 1 : -1)]
this.getMsgs({ if (nearMsg && nearMsg.id != rangeValue) {
dialog_id: this.dialogId, this.preventMoreLoad = true
msg_id: this.msgId, this.getMsgs({
msg_type: this.msgType, dialog_id: this.dialogId,
[key]: rangeValue, msg_id: this.msgId,
}).finally(_ => { msg_type: this.msgType,
this.preventMoreLoad = false [key]: rangeValue,
}) }).finally(_ => {
} this.preventMoreLoad = false
})
} }
} }
}, },

View File

@ -1584,11 +1584,7 @@
} }
.dialog-footer { .dialog-footer {
position: absolute; position: relative;
left: 0;
right: 0;
bottom: 0;
z-index: 2;
padding: 0 24px; padding: 0 24px;
margin-bottom: 16px; margin-bottom: 16px;