From 19fa164c75eea6c982b67283f92d5a6df1c2515b Mon Sep 17 00:00:00 2001 From: kuaifan Date: Sat, 3 Dec 2022 17:56:42 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=95=B0=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/js/components/Mobile/Tabbar.vue | 37 +++++++++++++++---- resources/assets/js/pages/manage.vue | 37 +++++++++++++++---- 2 files changed, 58 insertions(+), 16 deletions(-) diff --git a/resources/assets/js/components/Mobile/Tabbar.vue b/resources/assets/js/components/Mobile/Tabbar.vue index c523d3f62..afcd92dd4 100644 --- a/resources/assets/js/components/Mobile/Tabbar.vue +++ b/resources/assets/js/components/Mobile/Tabbar.vue @@ -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, }); } }, diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index a7913c008..4c30d4656 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -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);