From bbb797c4115c2d85f04fd4df007dc29aac25112a Mon Sep 17 00:00:00 2001 From: bboysoul Date: Tue, 8 Sep 2026 18:27:33 +0800 Subject: [PATCH] refactor: simplify today progress summary --- frontend/src/App.vue | 17 +++-------------- frontend/src/style.css | 6 +++--- frontend/src/style.test.ts | 11 +++++++++-- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 3da134a..1e7160a 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -241,14 +241,10 @@ const activeName = computed(() => { if (activeView.value === 'settings') return '设置与数据' return lists.value.find((item) => item.id === activeList.value)?.name || '收集箱' }) -const todayCompletedTasks = computed(() => activeView.value === 'today' ? tasks.value.filter((task) => task.completed).length : 0) -const todayOpenTasks = computed(() => activeView.value === 'today' ? Math.max(todayTaskTotal.value - todayTaskCompleted.value, 0) : 0) const todayHabitProgress = computed(() => `${todayHabitCompleted.value} / ${todayHabitTotal.value}`) const progressWidth = (completed: number, total: number) => `${total > 0 ? Math.min(100, Math.round(completed / total * 100)) : 0}%` const todayTaskProgressPercent = computed(() => progressWidth(todayTaskCompleted.value, todayTaskTotal.value)) const todayHabitProgressPercent = computed(() => progressWidth(todayHabitCompleted.value, todayHabitTotal.value)) -const todayTaskProgressHint = computed(() => todayTaskTotal.value ? `还剩 ${todayOpenTasks.value} 件` : '今天暂无任务') -const todayHabitProgressHint = computed(() => todayHabitTotal.value ? `还有 ${Math.max(todayHabitTotal.value - todayHabitCompleted.value, 0)} 项未完成` : '今天暂无习惯') function scrollTodaySection(id: 'today-tasks' | 'today-habits') { document.getElementById(id)?.scrollIntoView({ behavior: 'smooth', block: 'start' }) } @@ -256,12 +252,6 @@ function updateTodayHabitSummary(value: { total: number; completed: number }) { todayHabitTotal.value = value.total todayHabitCompleted.value = value.completed } -const todayProgressText = computed(() => { - if (activeView.value !== 'today') return '' - if (!todayTaskTotal.value) return '今天还没有任务' - if (!todayOpenTasks.value) return '今天任务都清掉了' - return `还有 ${todayOpenTasks.value} 件事要处理` -}) const sourceTasks = computed(() => activeView.value === 'trash' ? trash.value : tasks.value) const visibleTasks = computed(() => { const now = new Date() @@ -810,7 +800,7 @@ onMounted(bootstrap)
-

{{ activeName }}

{{ todayProgressText }},慢慢来。

+

{{ activeName }}