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

View File

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