From 367d7a0ae856f8c6dafa96d3d0ccdc04405a6328 Mon Sep 17 00:00:00 2001 From: kuaifan Date: Tue, 12 Jul 2022 12:56:09 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=A7=92=E6=A0=87=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E5=BE=85=E5=8A=9E=E8=B7=9F@=E4=B8=80=E8=B5=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/js/components/Mobile/Tabbar.vue | 22 +++++++-------- resources/assets/js/pages/manage.vue | 28 ++++++++----------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/resources/assets/js/components/Mobile/Tabbar.vue b/resources/assets/js/components/Mobile/Tabbar.vue index 5ee44d06d..f21d8ccf2 100644 --- a/resources/assets/js/components/Mobile/Tabbar.vue +++ b/resources/assets/js/components/Mobile/Tabbar.vue @@ -88,28 +88,26 @@ export default { }, msgUnreadMention() { - if (this.msgTodoTotal) { - return this.msgTodoTotal - } let num = 0; let mention = 0; this.cacheDialogs.some(dialog => { num += $A.getDialogUnread(dialog); mention += $A.getDialogMention(dialog); }) - if (num <= 0) { - return ''; - } if (num > 99) { num = "99+" } - if (mention > 0) { - if (mention > 99) { - return "@99+" - } - return `${num}·@${mention}` + if (mention > 99) { + mention = "99+" } - return String(num); + const todoNum = this.msgTodoTotal + if (todoNum) { + return mention ? `${todoNum}·@${mention}` : todoNum; + } + if (!num) { + return ""; + } + return mention ? `${num}·@${mention}` : String(num); }, msgTodoTotal() { diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index f6a52e024..7090ab8ff 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -510,28 +510,26 @@ export default { }, msgUnreadMention() { - if (this.msgTodoTotal) { - return this.msgTodoTotal - } let num = 0; let mention = 0; this.cacheDialogs.some(dialog => { num += $A.getDialogUnread(dialog); mention += $A.getDialogMention(dialog); }) - if (num <= 0) { - return ''; - } if (num > 99) { num = "99+" } - if (mention > 0) { - if (mention > 99) { - return "@99+" - } - return `${num}·@${mention}` + if (mention > 99) { + mention = "99+" } - return String(num); + const todoNum = this.msgTodoTotal + if (todoNum) { + return mention ? `${todoNum}·@${mention}` : todoNum; + } + if (!num) { + return ""; + } + return mention ? `${num}·@${mention}` : String(num); }, msgAllUnread() { @@ -557,10 +555,8 @@ export default { unreadTotal() { if (this.userId > 0) { - if (this.msgTodoTotal) { - return this.msgTodoTotal - } - return this.msgAllUnread + this.dashboardTask.overdue_count + this.reportUnreadNumber + const todoNum = this.cacheDialogs.reduce((total, current) => total + (current.todo_num || 0), 0) + return this.msgAllUnread + this.dashboardTask.overdue_count + this.reportUnreadNumber + todoNum } else { return 0 }