feat: add habits to today overview
This commit is contained in:
@@ -50,6 +50,8 @@ const showCompleted = ref(readStoredBoolean(window.localStorage, SHOW_COMPLETED_
|
||||
const page = ref(1)
|
||||
const pageSize = 50
|
||||
const totalTasks = ref(0)
|
||||
const todayHabitTotal = ref(0)
|
||||
const todayHabitCompleted = ref(0)
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(totalTasks.value / pageSize)))
|
||||
const expandedFolders = ref(new Set<string>())
|
||||
const collapsedTaskIds = ref(new Set<string>())
|
||||
@@ -218,6 +220,11 @@ const activeName = computed(() => {
|
||||
})
|
||||
const todayCompletedTasks = computed(() => activeView.value === 'today' ? tasks.value.filter((task) => task.completed).length : 0)
|
||||
const todayOpenTasks = computed(() => activeView.value === 'today' ? Math.max(totalTasks.value - todayCompletedTasks.value, 0) : 0)
|
||||
const todayHabitProgress = computed(() => `${todayHabitCompleted.value} / ${todayHabitTotal.value}`)
|
||||
function updateTodayHabitSummary(value: { total: number; completed: number }) {
|
||||
todayHabitTotal.value = value.total
|
||||
todayHabitCompleted.value = value.completed
|
||||
}
|
||||
const todayProgressText = computed(() => {
|
||||
if (activeView.value !== 'today') return ''
|
||||
if (!totalTasks.value) return '今天还没有任务'
|
||||
@@ -732,7 +739,7 @@ onMounted(bootstrap)
|
||||
<section v-if="activeView==='today'" class="today-board" aria-label="今日概览">
|
||||
<div class="today-stat"><strong>{{ todayOpenTasks }}</strong><span>待处理</span></div>
|
||||
<div class="today-stat"><strong>{{ todayCompletedTasks }}</strong><span>已完成</span></div>
|
||||
<div class="today-stat muted"><strong>{{ totalTasks }}</strong><span>今日任务</span></div>
|
||||
<div class="today-stat habit-stat"><strong>{{ todayHabitProgress }}</strong><span>习惯打卡</span></div>
|
||||
</section>
|
||||
<template v-if="activeView==='today'">
|
||||
<section v-if="overdueTaskTree.length" class="overdue-section">
|
||||
@@ -764,7 +771,7 @@ onMounted(bootstrap)
|
||||
</section>
|
||||
<div v-if="activeView==='today'">
|
||||
<h3 class="section-heading"><Repeat2/>习惯</h3>
|
||||
<MvpPanel ref="habitComposer" view="today-habits" @changed="refreshAll" @notice="toast" />
|
||||
<MvpPanel ref="habitComposer" view="today-habits" @changed="refreshAll" @notice="toast" @summary="updateTodayHabitSummary" />
|
||||
</div>
|
||||
</template>
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user