no message

This commit is contained in:
kuaifan 2024-01-10 14:23:38 +08:00
parent f380b0433d
commit bea7ba00f0

View File

@ -180,7 +180,6 @@
:data-sources="allMsgs" :data-sources="allMsgs"
:data-component="msgItem" :data-component="msgItem"
:item-class-add="itemClassAdd"
:extra-props="{dialogData, operateVisible, operateItem, isMyDialog, msgId, unreadOne, scrollIng, readEnabled}" :extra-props="{dialogData, operateVisible, operateItem, isMyDialog, msgId, unreadOne, scrollIng, readEnabled}"
:estimate-size="dialogData.type=='group' ? 105 : 77" :estimate-size="dialogData.type=='group' ? 105 : 77"
:keeps="keeps" :keeps="keeps"
@ -679,7 +678,7 @@ export default {
tempMsgs: [], tempMsgs: [],
tempId: $A.randNum(1000000000, 9999999999), tempId: $A.randNum(1000000000, 9999999999),
msgLoadIng: 0, msgLoadIng: 0,
msgActiveIndex: -1, msgActiveId: 0,
pasteShow: false, pasteShow: false,
pasteFile: [], pasteFile: [],
@ -1154,6 +1153,7 @@ export default {
dialogId: { dialogId: {
handler(dialog_id, old_id) { handler(dialog_id, old_id) {
if (dialog_id) { if (dialog_id) {
this.scrollInit()
this.msgNew = 0 this.msgNew = 0
this.msgType = '' this.msgType = ''
this.unreadOne = 0 this.unreadOne = 0
@ -1348,10 +1348,10 @@ 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] ? oldList[oldList.length - 1].id : 0
const tmpList = newList.filter(item => item.id && item.id > lastId && !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 {
!this.preventToBottom && this.$nextTick(this.onToBottom) !this.preventToBottom && this.onToBottom()
} }
}, },
@ -1381,9 +1381,14 @@ export default {
} }
}, },
msgActiveIndex(index) { msgActiveId(val) {
if (index > -1) { if (val > 0) {
setTimeout(_ => this.msgActiveIndex = -1, 800) this.msgActiveId = 0
const element = this.$refs.scroller.$el.querySelector(`[data-id="${val}"]`)?.querySelector(".dialog-head")
if (element) {
element.classList.add("common-shake")
setTimeout(_ => element.classList.remove("common-shake"), 800)
}
} }
}, },
@ -1691,7 +1696,7 @@ export default {
const gtpos = this.prevId > 0 ? 0 : -1 // const gtpos = this.prevId > 0 ? 0 : -1 //
if (index > gtpos) { if (index > gtpos) {
setTimeout(_ => { setTimeout(_ => {
this.onToIndex(index) this.onToIndex(index, position_id)
resolve() resolve()
}, 200) }, 200)
} else { } else {
@ -1711,7 +1716,7 @@ export default {
}).finally(_ => { }).finally(_ => {
const index = this.allMsgs.findIndex(item => item.id === position_id) const index = this.allMsgs.findIndex(item => item.id === position_id)
if (index > -1) { if (index > -1) {
this.onToIndex(index) this.onToIndex(index, position_id)
resolve() resolve()
} }
if (msg_id > 0) { if (msg_id > 0) {
@ -1797,10 +1802,6 @@ export default {
}); });
}, },
itemClassAdd(index) {
return index === this.msgActiveIndex ? 'common-shake' : '';
},
inputFocus() { inputFocus() {
this.$nextTick(_ => { this.$nextTick(_ => {
this.$refs.input && this.$refs.input.focus() this.$refs.input && this.$refs.input.focus()
@ -2116,30 +2117,32 @@ export default {
const scroller = this.$refs.scroller; const scroller = this.$refs.scroller;
if (scroller) { if (scroller) {
scroller.scrollToBottom(); scroller.scrollToBottom();
requestAnimationFrame(_ => scroller.scrollToBottom()) //
} }
}, },
onToIndex(index) { onToIndex(index, id) {
const scroller = this.$refs.scroller; const scroller = this.$refs.scroller;
if (scroller) { if (scroller) {
scroller.stopToBottom(); scroller.stopToBottom();
scroller.scrollToIndex(index, -100); const element = scroller.$el.querySelector(`[data-id="${id}"]`)
requestAnimationFrame(_ => scroller.scrollToIndex(index, -100)) // if (!element?.parentNode.parentNode.classList.contains('item-enter')) {
scroller.scrollToIndex(index, -80);
} }
requestAnimationFrame(_ => this.msgActiveIndex = index) }
requestAnimationFrame(_ => this.msgActiveId = id)
}, },
onToOffset(offset) { onToOffset(offset) {
const scroller = this.$refs.scroller; const scroller = this.$refs.scroller;
if (scroller) { if (scroller) {
const front = scroller.getOffset() > offset
scroller.stopToBottom(); scroller.stopToBottom();
scroller.scrollToOffset(offset); scroller.scrollToOffset(offset);
setTimeout(_ => { if (front) {
scroller.scrollToOffset(offset)
scroller.virtual.handleFront() scroller.virtual.handleFront()
// scroller.virtual.handleBehind() } else {
}, 10) // scroller.virtual.handleBehind()
}
} }
}, },
@ -2160,6 +2163,17 @@ export default {
return true return true
}, },
scrollInit() {
const scroller = this.$refs.scroller;
if (scroller) {
const scrollEl = scroller.$el
scrollEl.style.visibility = 'hidden'
this.$nextTick(_ => {
scrollEl.style.visibility = 'visible'
})
}
},
scrollInfo() { scrollInfo() {
const scroller = this.$refs.scroller; const scroller = this.$refs.scroller;
if (scroller) { if (scroller) {