perf: 优化消息列表

This commit is contained in:
Pang 2023-12-24 19:30:36 +08:00
parent 9300e9fd9a
commit 4506ba8cd3
2 changed files with 27 additions and 15 deletions

View File

@ -731,7 +731,8 @@ export default {
unreadMsgId: 0, // id
positionLoad: 0, //
isFirstPageReady: false, //
firstMsgLength: 0, //
isFirstShowTag: false, //
msgPreparedStatus: false, //
listPreparedStatus: false, //
selectedTextStatus: false, //
@ -867,32 +868,32 @@ export default {
return '发送文件'
},
msgTags() {
msgTags({dialogData}) {
const array = [
{type: '', label: '消息'},
];
if (this.dialogData.has_tag) {
if (dialogData.has_tag) {
array.push({type: 'tag', label: '标注'})
}
if (this.dialogData.has_todo) {
if (dialogData.has_todo) {
array.push({type: 'todo', label: '事项'})
}
if (this.dialogData.has_image) {
if (dialogData.has_image) {
array.push({type: 'image', label: '图片'})
}
if (this.dialogData.has_file) {
if (dialogData.has_file) {
array.push({type: 'file', label: '文件'})
}
if (this.dialogData.has_link) {
if (dialogData.has_link) {
array.push({type: 'link', label: '链接'})
}
if (this.dialogData.group_type === 'project') {
if (dialogData.group_type === 'project') {
array.push({type: 'project', label: '打开项目'})
}
if (this.dialogData.group_type === 'task') {
if (dialogData.group_type === 'task') {
array.push({type: 'task', label: '打开任务'})
}
if (this.dialogData.group_type === 'okr') {
if (dialogData.group_type === 'okr') {
array.push({type: 'okr', label: '打开OKR'})
}
return array
@ -1088,11 +1089,11 @@ export default {
this.msgType = ''
this.searchShow = false
this.unreadMsgId = 0
this.isFirstPageReady = false
this.firstMsgLength = this.allMsgList.length || 1
this.listPreparedStatus = false
this.scrollToBottomAndRefresh = false
//
if (this.allMsgList.length > 0) {
if (this.firstMsgLength > 0) {
this.allMsgs = this.allMsgList
requestAnimationFrame(this.onToBottom)
}
@ -1327,7 +1328,17 @@ export default {
if (msg) {
this.unreadMsgId = msg.msg_id
}
}
},
tagShow(val) {
if (!this.isFirstShowTag && val) {
this.isFirstShowTag = true
const {tail} = this.scrollInfo();
if (tail <= 55) {
requestAnimationFrame(this.onToBottom)
}
}
},
},
methods: {
@ -2152,8 +2163,8 @@ export default {
if (!this.$refs.scroller || !this.$refs.footer) {
return
}
if (!this.isFirstPageReady) {
this.isFirstPageReady = true
if (this.firstMsgLength > 0 && this.$refs.scroller.getSizes() >= this.firstMsgLength) {
this.firstMsgLength = 0
this.onFooterResize()
this.onToBottom()
}

View File

@ -1437,6 +1437,7 @@
opacity: 0;
transform: translateX(100%);
animation: position-in-animation 200ms ease-out forwards;
animation-delay: 300ms;
.position-label {
display: flex;