mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 19:23:26 +00:00
perf: 优化消息数量
This commit is contained in:
parent
1c090c1e5e
commit
19fa164c75
@ -89,9 +89,13 @@ export default {
|
|||||||
return this.$route.name
|
return this.$route.name
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合数(未读、提及、待办)
|
||||||
|
* @returns {string|string}
|
||||||
|
*/
|
||||||
msgUnreadMention() {
|
msgUnreadMention() {
|
||||||
let num = 0;
|
let num = 0; // 未读
|
||||||
let mention = 0;
|
let mention = 0; // 提及
|
||||||
this.cacheDialogs.some(dialog => {
|
this.cacheDialogs.some(dialog => {
|
||||||
num += $A.getDialogUnread(dialog);
|
num += $A.getDialogUnread(dialog);
|
||||||
mention += $A.getDialogMention(dialog);
|
mention += $A.getDialogMention(dialog);
|
||||||
@ -102,9 +106,15 @@ export default {
|
|||||||
if (mention > 99) {
|
if (mention > 99) {
|
||||||
mention = "99+"
|
mention = "99+"
|
||||||
}
|
}
|
||||||
const todoNum = this.msgTodoTotal
|
const todoNum = this.msgTodoTotal // 待办
|
||||||
if (todoNum) {
|
if (todoNum) {
|
||||||
return mention ? `${todoNum}·@${mention}` : todoNum;
|
if (mention) {
|
||||||
|
return `@${mention}·${todoNum}`
|
||||||
|
}
|
||||||
|
if (num) {
|
||||||
|
return `${num}·${todoNum}`
|
||||||
|
}
|
||||||
|
return todoNum;
|
||||||
}
|
}
|
||||||
if (!num) {
|
if (!num) {
|
||||||
return "";
|
return "";
|
||||||
@ -112,6 +122,10 @@ export default {
|
|||||||
return mention ? `${num}·@${mention}` : String(num);
|
return mention ? `${num}·@${mention}` : String(num);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未读消息数
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
msgAllUnread() {
|
msgAllUnread() {
|
||||||
let num = 0;
|
let num = 0;
|
||||||
this.cacheDialogs.some(dialog => {
|
this.cacheDialogs.some(dialog => {
|
||||||
@ -120,6 +134,10 @@ export default {
|
|||||||
return num;
|
return num;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 待办消息数
|
||||||
|
* @returns {string|null}
|
||||||
|
*/
|
||||||
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) {
|
||||||
@ -133,10 +151,13 @@ export default {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
unreadTotal() {
|
/**
|
||||||
|
* 未读消息 + 逾期任务
|
||||||
|
* @returns {number|*}
|
||||||
|
*/
|
||||||
|
unreadAndOverdue() {
|
||||||
if (this.userId > 0) {
|
if (this.userId > 0) {
|
||||||
const todoNum = this.cacheDialogs.reduce((total, current) => total + (current.todo_num || 0), 0)
|
return this.msgAllUnread + this.dashboardTask.overdue_count
|
||||||
return this.msgAllUnread + this.dashboardTask.overdue_count + todoNum
|
|
||||||
} else {
|
} else {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -170,7 +191,7 @@ export default {
|
|||||||
if (!active) {
|
if (!active) {
|
||||||
$A.eeuiAppSendMessage({
|
$A.eeuiAppSendMessage({
|
||||||
action: 'setBdageNotify',
|
action: 'setBdageNotify',
|
||||||
bdage: this.unreadTotal,
|
bdage: this.unreadAndOverdue,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -519,9 +519,13 @@ export default {
|
|||||||
return this.$route.name
|
return this.$route.name
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 综合数(未读、提及、待办)
|
||||||
|
* @returns {string|string}
|
||||||
|
*/
|
||||||
msgUnreadMention() {
|
msgUnreadMention() {
|
||||||
let num = 0;
|
let num = 0; // 未读
|
||||||
let mention = 0;
|
let mention = 0; // 提及
|
||||||
this.cacheDialogs.some(dialog => {
|
this.cacheDialogs.some(dialog => {
|
||||||
num += $A.getDialogUnread(dialog);
|
num += $A.getDialogUnread(dialog);
|
||||||
mention += $A.getDialogMention(dialog);
|
mention += $A.getDialogMention(dialog);
|
||||||
@ -532,9 +536,15 @@ export default {
|
|||||||
if (mention > 99) {
|
if (mention > 99) {
|
||||||
mention = "99+"
|
mention = "99+"
|
||||||
}
|
}
|
||||||
const todoNum = this.msgTodoTotal
|
const todoNum = this.msgTodoTotal // 待办
|
||||||
if (todoNum) {
|
if (todoNum) {
|
||||||
return mention ? `${todoNum}·@${mention}` : todoNum;
|
if (mention) {
|
||||||
|
return `@${mention}·${todoNum}`
|
||||||
|
}
|
||||||
|
if (num) {
|
||||||
|
return `${num}·${todoNum}`
|
||||||
|
}
|
||||||
|
return todoNum;
|
||||||
}
|
}
|
||||||
if (!num) {
|
if (!num) {
|
||||||
return "";
|
return "";
|
||||||
@ -542,6 +552,10 @@ export default {
|
|||||||
return mention ? `${num}·@${mention}` : String(num);
|
return mention ? `${num}·@${mention}` : String(num);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 未读消息数
|
||||||
|
* @returns {number}
|
||||||
|
*/
|
||||||
msgAllUnread() {
|
msgAllUnread() {
|
||||||
let num = 0;
|
let num = 0;
|
||||||
this.cacheDialogs.some(dialog => {
|
this.cacheDialogs.some(dialog => {
|
||||||
@ -550,6 +564,10 @@ export default {
|
|||||||
return num;
|
return num;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 待办消息数
|
||||||
|
* @returns {string|null}
|
||||||
|
*/
|
||||||
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) {
|
||||||
@ -563,10 +581,13 @@ export default {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
unreadTotal() {
|
/**
|
||||||
|
* 未读消息 + 逾期任务
|
||||||
|
* @returns {number|*}
|
||||||
|
*/
|
||||||
|
unreadAndOverdue() {
|
||||||
if (this.userId > 0) {
|
if (this.userId > 0) {
|
||||||
const todoNum = this.cacheDialogs.reduce((total, current) => total + (current.todo_num || 0), 0)
|
return this.msgAllUnread + this.dashboardTask.overdue_count
|
||||||
return this.msgAllUnread + this.dashboardTask.overdue_count + this.reportUnreadNumber + todoNum
|
|
||||||
} else {
|
} else {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -717,7 +738,7 @@ export default {
|
|||||||
immediate: true
|
immediate: true
|
||||||
},
|
},
|
||||||
|
|
||||||
unreadTotal: {
|
unreadAndOverdue: {
|
||||||
handler(val) {
|
handler(val) {
|
||||||
if (this.$Electron) {
|
if (this.$Electron) {
|
||||||
this.$Electron.sendMessage('setDockBadge', val);
|
this.$Electron.sendMessage('setDockBadge', val);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user