mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-11 18:35:54 +00:00
perf: 优化消息数量显示
This commit is contained in:
parent
aa5da2479c
commit
bf941b7ec4
@ -119,11 +119,11 @@ export default {
|
|||||||
num += $A.getDialogUnread(dialog, false);
|
num += $A.getDialogUnread(dialog, false);
|
||||||
mention += $A.getDialogMention(dialog);
|
mention += $A.getDialogMention(dialog);
|
||||||
})
|
})
|
||||||
if (num > 99) {
|
if (num > 999) {
|
||||||
num = "99+"
|
num = "999+"
|
||||||
}
|
}
|
||||||
if (mention > 99) {
|
if (mention > 999) {
|
||||||
mention = "99+"
|
mention = "999+"
|
||||||
}
|
}
|
||||||
const todoNum = this.msgTodoTotal // 待办
|
const todoNum = this.msgTodoTotal // 待办
|
||||||
if (todoNum) {
|
if (todoNum) {
|
||||||
@ -135,10 +135,16 @@ export default {
|
|||||||
}
|
}
|
||||||
return todoNum;
|
return todoNum;
|
||||||
}
|
}
|
||||||
if (!num) {
|
if (num) {
|
||||||
return "";
|
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() {
|
msgAllUnread() {
|
||||||
let num = 0;
|
let num = 0;
|
||||||
this.cacheDialogs.some(dialog => {
|
this.cacheDialogs.some(dialog => {
|
||||||
num += $A.getDialogUnread(dialog, false);
|
num += $A.getDialogNum(dialog);
|
||||||
})
|
})
|
||||||
return num;
|
return num;
|
||||||
},
|
},
|
||||||
@ -160,8 +166,8 @@ export default {
|
|||||||
msgTodoTotal() {
|
msgTodoTotal() {
|
||||||
let todoNum = this.cacheDialogs.reduce((total, current) => total + (current.todo_num || 0), 0)
|
let todoNum = this.cacheDialogs.reduce((total, current) => total + (current.todo_num || 0), 0)
|
||||||
if (todoNum > 0) {
|
if (todoNum > 0) {
|
||||||
if (todoNum > 99) {
|
if (todoNum > 999) {
|
||||||
todoNum = "99+"
|
todoNum = "999+"
|
||||||
} else if (todoNum === 1) {
|
} else if (todoNum === 1) {
|
||||||
todoNum = ""
|
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');
|
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 dialog
|
||||||
* @param containSilence
|
* @param containSilence 是否包含免打扰消息(true:包含, false:不包含)
|
||||||
* @returns {*|number}
|
* @returns {*|number}
|
||||||
*/
|
*/
|
||||||
getDialogUnread(dialog, containSilence) {
|
getDialogUnread(dialog, containSilence) {
|
||||||
const unread = containSilence || !dialog.silence ? dialog.unread : 0
|
if (!dialog) {
|
||||||
return dialog ? (unread || dialog.mark_unread || 0) : 0
|
return 0
|
||||||
|
}
|
||||||
|
const unread = (containSilence || !dialog.silence) ? dialog.unread : 0
|
||||||
|
return unread || dialog.mark_unread || 0
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -646,7 +662,7 @@
|
|||||||
* @returns {*|number}
|
* @returns {*|number}
|
||||||
*/
|
*/
|
||||||
getDialogMention(dialog) {
|
getDialogMention(dialog) {
|
||||||
return dialog ? (dialog.mention || 0) : 0
|
return dialog?.mention || 0
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -477,10 +477,16 @@ export default {
|
|||||||
}
|
}
|
||||||
return todoNum;
|
return todoNum;
|
||||||
}
|
}
|
||||||
if (!num) {
|
if (num) {
|
||||||
return "";
|
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() {
|
msgAllUnread() {
|
||||||
let num = 0;
|
let num = 0;
|
||||||
this.cacheDialogs.some(dialog => {
|
this.cacheDialogs.some(dialog => {
|
||||||
num += $A.getDialogUnread(dialog, false);
|
num += $A.getDialogNum(dialog);
|
||||||
})
|
})
|
||||||
return num;
|
return num;
|
||||||
},
|
},
|
||||||
|
|||||||
@ -726,13 +726,13 @@ export default {
|
|||||||
msgUnreadOnly() {
|
msgUnreadOnly() {
|
||||||
let num = 0;
|
let num = 0;
|
||||||
this.cacheDialogs.some(dialog => {
|
this.cacheDialogs.some(dialog => {
|
||||||
num += $A.getDialogUnread(dialog, false);
|
num += $A.getDialogNum(dialog);
|
||||||
})
|
})
|
||||||
if (num <= 0) {
|
if (num <= 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
if (num > 99) {
|
if (num > 999) {
|
||||||
num = "99+"
|
num = "999+"
|
||||||
}
|
}
|
||||||
return String(num);
|
return String(num);
|
||||||
},
|
},
|
||||||
|
|||||||
@ -30,7 +30,7 @@
|
|||||||
<li v-for="(userid, index) in editUser" :key="index" v-if="index <= 10">
|
<li v-for="(userid, index) in editUser" :key="index" v-if="index <= 10">
|
||||||
<UserAvatar :userid="userid" :size="28" :border-witdh="2"/>
|
<UserAvatar :userid="userid" :size="28" :border-witdh="2"/>
|
||||||
</li>
|
</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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="file.type=='document' && contentDetail" class="header-hint">
|
<div v-if="file.type=='document' && contentDetail" class="header-hint">
|
||||||
|
|||||||
@ -592,7 +592,7 @@ export default {
|
|||||||
msgUnread() {
|
msgUnread() {
|
||||||
const {cacheDialogs, projectData} = this;
|
const {cacheDialogs, projectData} = this;
|
||||||
const dialog = cacheDialogs.find(({id}) => id === projectData.dialog_id);
|
const dialog = cacheDialogs.find(({id}) => id === projectData.dialog_id);
|
||||||
return dialog ? $A.getDialogUnread(dialog, false) : 0;
|
return $A.getDialogNum(dialog);
|
||||||
},
|
},
|
||||||
|
|
||||||
panelTask() {
|
panelTask() {
|
||||||
|
|||||||
@ -422,7 +422,7 @@
|
|||||||
<div v-if="navActive=='dialog' && taskDetail.msg_num > 0" class="menu-item" @click.stop="onSend('open')">
|
<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>
|
<div v-if="openLoad > 0" class="menu-load"><Loading/></div>
|
||||||
{{$L('任务聊天')}}
|
{{$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>
|
<i class="taskfont"></i>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -350,27 +350,22 @@ export default {
|
|||||||
|
|
||||||
msgUnread() {
|
msgUnread() {
|
||||||
return function (type) {
|
return function (type) {
|
||||||
let num = 0;
|
let num = 0
|
||||||
this.cacheDialogs.some((dialog) => {
|
this.cacheDialogs.some((dialog) => {
|
||||||
let unread = $A.getDialogUnread(dialog, false);
|
switch (type) {
|
||||||
if (unread) {
|
case 'project':
|
||||||
switch (type) {
|
case 'task':
|
||||||
case 'project':
|
if (type != dialog.group_type) {
|
||||||
case 'task':
|
return false
|
||||||
if (type == dialog.group_type) {
|
}
|
||||||
num += unread;
|
break;
|
||||||
}
|
case 'user':
|
||||||
break;
|
if (type != dialog.type) {
|
||||||
case 'user':
|
return false
|
||||||
if (type == dialog.type) {
|
}
|
||||||
num += unread;
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
num += unread;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
num += $A.getDialogNum(dialog);
|
||||||
});
|
});
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
@ -481,7 +476,7 @@ export default {
|
|||||||
onActive(type) {
|
onActive(type) {
|
||||||
if (this.dialogActive == 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) {
|
if (dialog) {
|
||||||
$A.scrollIntoViewIfNeeded(this.$refs[`dialog_${dialog.id}`][0])
|
$A.scrollIntoViewIfNeeded(this.$refs[`dialog_${dialog.id}`][0])
|
||||||
}
|
}
|
||||||
@ -532,7 +527,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
filterDialog(dialog) {
|
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
|
return true
|
||||||
}
|
}
|
||||||
if (dialog.name === undefined || dialog.dialog_delete === 1) {
|
if (dialog.name === undefined || dialog.dialog_delete === 1) {
|
||||||
@ -643,7 +638,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
formatTodoNum(num) {
|
formatTodoNum(num) {
|
||||||
return num > 99 ? '99+' : (num > 1 ? num : '')
|
return num > 999 ? '999+' : (num > 1 ? num : '')
|
||||||
},
|
},
|
||||||
|
|
||||||
formatMsgEmojiDesc(data) {
|
formatMsgEmojiDesc(data) {
|
||||||
|
|||||||
@ -105,6 +105,7 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
top: -6px;
|
top: -6px;
|
||||||
left: 20px;
|
left: 20px;
|
||||||
|
z-index: 1;
|
||||||
transform: scale(0.8);
|
transform: scale(0.8);
|
||||||
}
|
}
|
||||||
.search-input {
|
.search-input {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user