perf: 优化消息数量

This commit is contained in:
kuaifan 2022-12-03 17:56:42 +08:00
parent 1c090c1e5e
commit 19fa164c75
2 changed files with 58 additions and 16 deletions

View File

@ -89,9 +89,13 @@ export default {
return this.$route.name
},
/**
* 综合数未读提及待办
* @returns {string|string}
*/
msgUnreadMention() {
let num = 0;
let mention = 0;
let num = 0; //
let mention = 0; //
this.cacheDialogs.some(dialog => {
num += $A.getDialogUnread(dialog);
mention += $A.getDialogMention(dialog);
@ -102,9 +106,15 @@ export default {
if (mention > 99) {
mention = "99+"
}
const todoNum = this.msgTodoTotal
const todoNum = this.msgTodoTotal //
if (todoNum) {
return mention ? `${todoNum}·@${mention}` : todoNum;
if (mention) {
return `@${mention}·${todoNum}`
}
if (num) {
return `${num}·${todoNum}`
}
return todoNum;
}
if (!num) {
return "";
@ -112,6 +122,10 @@ export default {
return mention ? `${num}·@${mention}` : String(num);
},
/**
* 未读消息数
* @returns {number}
*/
msgAllUnread() {
let num = 0;
this.cacheDialogs.some(dialog => {
@ -120,6 +134,10 @@ export default {
return num;
},
/**
* 待办消息数
* @returns {string|null}
*/
msgTodoTotal() {
let todoNum = this.cacheDialogs.reduce((total, current) => total + (current.todo_num || 0), 0)
if (todoNum > 0) {
@ -133,10 +151,13 @@ export default {
return null;
},
unreadTotal() {
/**
* 未读消息 + 逾期任务
* @returns {number|*}
*/
unreadAndOverdue() {
if (this.userId > 0) {
const todoNum = this.cacheDialogs.reduce((total, current) => total + (current.todo_num || 0), 0)
return this.msgAllUnread + this.dashboardTask.overdue_count + todoNum
return this.msgAllUnread + this.dashboardTask.overdue_count
} else {
return 0
}
@ -170,7 +191,7 @@ export default {
if (!active) {
$A.eeuiAppSendMessage({
action: 'setBdageNotify',
bdage: this.unreadTotal,
bdage: this.unreadAndOverdue,
});
}
},

View File

@ -519,9 +519,13 @@ export default {
return this.$route.name
},
/**
* 综合数未读提及待办
* @returns {string|string}
*/
msgUnreadMention() {
let num = 0;
let mention = 0;
let num = 0; //
let mention = 0; //
this.cacheDialogs.some(dialog => {
num += $A.getDialogUnread(dialog);
mention += $A.getDialogMention(dialog);
@ -532,9 +536,15 @@ export default {
if (mention > 99) {
mention = "99+"
}
const todoNum = this.msgTodoTotal
const todoNum = this.msgTodoTotal //
if (todoNum) {
return mention ? `${todoNum}·@${mention}` : todoNum;
if (mention) {
return `@${mention}·${todoNum}`
}
if (num) {
return `${num}·${todoNum}`
}
return todoNum;
}
if (!num) {
return "";
@ -542,6 +552,10 @@ export default {
return mention ? `${num}·@${mention}` : String(num);
},
/**
* 未读消息数
* @returns {number}
*/
msgAllUnread() {
let num = 0;
this.cacheDialogs.some(dialog => {
@ -550,6 +564,10 @@ export default {
return num;
},
/**
* 待办消息数
* @returns {string|null}
*/
msgTodoTotal() {
let todoNum = this.cacheDialogs.reduce((total, current) => total + (current.todo_num || 0), 0)
if (todoNum > 0) {
@ -563,10 +581,13 @@ export default {
return null;
},
unreadTotal() {
/**
* 未读消息 + 逾期任务
* @returns {number|*}
*/
unreadAndOverdue() {
if (this.userId > 0) {
const todoNum = this.cacheDialogs.reduce((total, current) => total + (current.todo_num || 0), 0)
return this.msgAllUnread + this.dashboardTask.overdue_count + this.reportUnreadNumber + todoNum
return this.msgAllUnread + this.dashboardTask.overdue_count
} else {
return 0
}
@ -717,7 +738,7 @@ export default {
immediate: true
},
unreadTotal: {
unreadAndOverdue: {
handler(val) {
if (this.$Electron) {
this.$Electron.sendMessage('setDockBadge', val);