mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-07 09:57:37 +00:00
perf: 优化消息数量显示
This commit is contained in:
parent
aa5da2479c
commit
bf941b7ec4
@ -119,11 +119,11 @@ export default {
|
||||
num += $A.getDialogUnread(dialog, false);
|
||||
mention += $A.getDialogMention(dialog);
|
||||
})
|
||||
if (num > 99) {
|
||||
num = "99+"
|
||||
if (num > 999) {
|
||||
num = "999+"
|
||||
}
|
||||
if (mention > 99) {
|
||||
mention = "99+"
|
||||
if (mention > 999) {
|
||||
mention = "999+"
|
||||
}
|
||||
const todoNum = this.msgTodoTotal // 待办
|
||||
if (todoNum) {
|
||||
@ -135,10 +135,16 @@ export default {
|
||||
}
|
||||
return todoNum;
|
||||
}
|
||||
if (!num) {
|
||||
return "";
|
||||
if (num) {
|
||||
if (mention) {
|
||||
return `${num}·@${mention}`
|
||||
}
|
||||
return String(num)
|
||||
}
|
||||
return mention ? `${num}·@${mention}` : String(num);
|
||||
if (mention) {
|
||||
return `@${mention}`
|
||||
}
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
@ -148,7 +154,7 @@ export default {
|
||||
msgAllUnread() {
|
||||
let num = 0;
|
||||
this.cacheDialogs.some(dialog => {
|
||||
num += $A.getDialogUnread(dialog, false);
|
||||
num += $A.getDialogNum(dialog);
|
||||
})
|
||||
return num;
|
||||
},
|
||||
@ -160,8 +166,8 @@ export default {
|
||||
msgTodoTotal() {
|
||||
let todoNum = this.cacheDialogs.reduce((total, current) => total + (current.todo_num || 0), 0)
|
||||
if (todoNum > 0) {
|
||||
if (todoNum > 99) {
|
||||
todoNum = "99+"
|
||||
if (todoNum > 999) {
|
||||
todoNum = "999+"
|
||||
} else if (todoNum === 1) {
|
||||
todoNum = ""
|
||||
}
|
||||
|
||||
24
resources/assets/js/functions/web.js
vendored
24
resources/assets/js/functions/web.js
vendored
@ -629,15 +629,31 @@
|
||||
return this.dialogTags(dialog).find(({color}) => color == 'success');
|
||||
},
|
||||
|
||||
/**
|
||||
* 返回对话未读数量(不含免打扰,但如果免打扰中有@则返回@数量)
|
||||
* @param dialog
|
||||
* @returns {*|number}
|
||||
*/
|
||||
getDialogNum(dialog) {
|
||||
if (!dialog) {
|
||||
return 0
|
||||
}
|
||||
const unread = !dialog.silence ? dialog.unread : 0
|
||||
return unread || dialog.mention || dialog.mark_unread || 0
|
||||
},
|
||||
|
||||
/**
|
||||
* 返回对话未读数量
|
||||
* @param dialog
|
||||
* @param containSilence
|
||||
* @param containSilence 是否包含免打扰消息(true:包含, false:不包含)
|
||||
* @returns {*|number}
|
||||
*/
|
||||
getDialogUnread(dialog, containSilence) {
|
||||
const unread = containSilence || !dialog.silence ? dialog.unread : 0
|
||||
return dialog ? (unread || dialog.mark_unread || 0) : 0
|
||||
if (!dialog) {
|
||||
return 0
|
||||
}
|
||||
const unread = (containSilence || !dialog.silence) ? dialog.unread : 0
|
||||
return unread || dialog.mark_unread || 0
|
||||
},
|
||||
|
||||
/**
|
||||
@ -646,7 +662,7 @@
|
||||
* @returns {*|number}
|
||||
*/
|
||||
getDialogMention(dialog) {
|
||||
return dialog ? (dialog.mention || 0) : 0
|
||||
return dialog?.mention || 0
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@ -477,10 +477,16 @@ export default {
|
||||
}
|
||||
return todoNum;
|
||||
}
|
||||
if (!num) {
|
||||
return "";
|
||||
if (num) {
|
||||
if (mention) {
|
||||
return `${num}·@${mention}`
|
||||
}
|
||||
return String(num)
|
||||
}
|
||||
return mention ? `${num}·@${mention}` : String(num);
|
||||
if (mention) {
|
||||
return `@${mention}`
|
||||
}
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
@ -490,7 +496,7 @@ export default {
|
||||
msgAllUnread() {
|
||||
let num = 0;
|
||||
this.cacheDialogs.some(dialog => {
|
||||
num += $A.getDialogUnread(dialog, false);
|
||||
num += $A.getDialogNum(dialog);
|
||||
})
|
||||
return num;
|
||||
},
|
||||
|
||||
@ -726,13 +726,13 @@ export default {
|
||||
msgUnreadOnly() {
|
||||
let num = 0;
|
||||
this.cacheDialogs.some(dialog => {
|
||||
num += $A.getDialogUnread(dialog, false);
|
||||
num += $A.getDialogNum(dialog);
|
||||
})
|
||||
if (num <= 0) {
|
||||
return '';
|
||||
}
|
||||
if (num > 99) {
|
||||
num = "99+"
|
||||
if (num > 999) {
|
||||
num = "999+"
|
||||
}
|
||||
return String(num);
|
||||
},
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
<li v-for="(userid, index) in editUser" :key="index" v-if="index <= 10">
|
||||
<UserAvatar :userid="userid" :size="28" :border-witdh="2"/>
|
||||
</li>
|
||||
<li v-if="editUser.length > 10" class="more">{{editUser.length > 99 ? '99+' : editUser.length}}</li>
|
||||
<li v-if="editUser.length > 10" class="more" :title="editUser.length">{{editUser.length > 999 ? '...' : editUser.length}}</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-if="file.type=='document' && contentDetail" class="header-hint">
|
||||
|
||||
@ -592,7 +592,7 @@ export default {
|
||||
msgUnread() {
|
||||
const {cacheDialogs, projectData} = this;
|
||||
const dialog = cacheDialogs.find(({id}) => id === projectData.dialog_id);
|
||||
return dialog ? $A.getDialogUnread(dialog, false) : 0;
|
||||
return $A.getDialogNum(dialog);
|
||||
},
|
||||
|
||||
panelTask() {
|
||||
|
||||
@ -422,7 +422,7 @@
|
||||
<div v-if="navActive=='dialog' && taskDetail.msg_num > 0" class="menu-item" @click.stop="onSend('open')">
|
||||
<div v-if="openLoad > 0" class="menu-load"><Loading/></div>
|
||||
{{$L('任务聊天')}}
|
||||
<em>({{taskDetail.msg_num > 99 ? '99+' : taskDetail.msg_num}})</em>
|
||||
<em>({{taskDetail.msg_num > 999 ? '999+' : taskDetail.msg_num}})</em>
|
||||
<i class="taskfont"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -350,27 +350,22 @@ export default {
|
||||
|
||||
msgUnread() {
|
||||
return function (type) {
|
||||
let num = 0;
|
||||
let num = 0
|
||||
this.cacheDialogs.some((dialog) => {
|
||||
let unread = $A.getDialogUnread(dialog, false);
|
||||
if (unread) {
|
||||
switch (type) {
|
||||
case 'project':
|
||||
case 'task':
|
||||
if (type == dialog.group_type) {
|
||||
num += unread;
|
||||
}
|
||||
break;
|
||||
case 'user':
|
||||
if (type == dialog.type) {
|
||||
num += unread;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
num += unread;
|
||||
break;
|
||||
}
|
||||
switch (type) {
|
||||
case 'project':
|
||||
case 'task':
|
||||
if (type != dialog.group_type) {
|
||||
return false
|
||||
}
|
||||
break;
|
||||
case 'user':
|
||||
if (type != dialog.type) {
|
||||
return false
|
||||
}
|
||||
break;
|
||||
}
|
||||
num += $A.getDialogNum(dialog);
|
||||
});
|
||||
return num;
|
||||
}
|
||||
@ -481,7 +476,7 @@ export default {
|
||||
onActive(type) {
|
||||
if (this.dialogActive == type) {
|
||||
// 再次点击滚动到未读条目
|
||||
const dialog = this.dialogList.find(dialog => $A.getDialogUnread(dialog, false) > 0)
|
||||
const dialog = this.dialogList.find(dialog => $A.getDialogNum(dialog) > 0)
|
||||
if (dialog) {
|
||||
$A.scrollIntoViewIfNeeded(this.$refs[`dialog_${dialog.id}`][0])
|
||||
}
|
||||
@ -532,7 +527,7 @@ export default {
|
||||
},
|
||||
|
||||
filterDialog(dialog) {
|
||||
if ($A.getDialogUnread(dialog, false) > 0 || dialog.id == this.dialogId || dialog.top_at || dialog.todo_num > 0) {
|
||||
if ($A.getDialogNum(dialog) > 0 || dialog.id == this.dialogId || dialog.top_at || dialog.todo_num > 0) {
|
||||
return true
|
||||
}
|
||||
if (dialog.name === undefined || dialog.dialog_delete === 1) {
|
||||
@ -643,7 +638,7 @@ export default {
|
||||
},
|
||||
|
||||
formatTodoNum(num) {
|
||||
return num > 99 ? '99+' : (num > 1 ? num : '')
|
||||
return num > 999 ? '999+' : (num > 1 ? num : '')
|
||||
},
|
||||
|
||||
formatMsgEmojiDesc(data) {
|
||||
|
||||
@ -105,6 +105,7 @@
|
||||
position: absolute;
|
||||
top: -6px;
|
||||
left: 20px;
|
||||
z-index: 1;
|
||||
transform: scale(0.8);
|
||||
}
|
||||
.search-input {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user