fix: refine task pagination controls
ci / gitleaks (push) Successful in 7s
ci / docker (push) Successful in 6m18s

This commit is contained in:
2026-09-21 06:30:52 +08:00
parent cbf307507c
commit c7bb9742f1
4 changed files with 13 additions and 14 deletions
@@ -39,7 +39,8 @@ test('task pagination stays below the list and returns to the list start after n
const pager = page.locator('.pager')
await expect(taskList.locator('.task-row')).toHaveCount(50)
await expect(pager).toBeVisible()
await expect(pager.locator('.pager-status')).toHaveText('1/ 2')
await expect(pager.locator('.pager-status')).toHaveText('1 / 2共 51 项')
await expect(page.locator('.list-page-meta')).toHaveCount(0)
const firstPageGeometry = await page.evaluate(() => {
const list = document.querySelector<HTMLElement>('.task-list')!.getBoundingClientRect()
@@ -81,7 +82,7 @@ test('task pagination stays below the list and returns to the list start after n
const focusOutline = await nextButton.evaluate(element => getComputedStyle(element).outlineStyle)
expect(focusOutline).not.toBe('none')
await nextButton.click()
await expect(pager.locator('.pager-status')).toHaveText('2/ 2')
await expect(pager.locator('.pager-status')).toHaveText('2 / 2共 51 项')
await expect(taskList.locator('.task-row')).toHaveCount(1)
const secondPageGeometry = await page.evaluate(() => {
+1 -2
View File
@@ -1745,8 +1745,7 @@ onUnmounted(() => {
<div v-if="activeView==='today' && hiddenCompletedTaskCount > 0 && !visibleTasks.length && !loading" class="today-filtered-empty-note"><span>已隐藏已完成任务</span><button type="button" class="link" @click="showCompleted=true">显示</button></div>
<div v-else-if="!visibleTasks.length&&!loading" class="empty"><ListTodo/><b>{{ hiddenCompletedTaskCount > 0 ? '已完成任务已隐藏' : '这里还很安静' }}</b><span>{{hiddenCompletedTaskCount > 0 ? '开启“显示已完成”即可查看。':'写下第一件想完成的小事吧'}}</span></div>
</section>
<div v-if="activeView==='tasks' && totalPages > 1" class="list-page-meta" aria-live="polite"><span>{{ page }} / {{ totalPages }} 页 · 共 {{ totalTasks }} 项</span></div>
<nav v-if="totalPages > 1 && (activeView!=='today' || !todaySectionCollapse.tasks)" class="pager" aria-label="任务分页"><button class="pager-button pager-button--previous" :disabled="page<=1 || loading" aria-label="上一页" @click="previousPage"><ChevronLeft aria-hidden="true"/><span>上一页</span></button><span class="pager-status" aria-live="polite"><strong>{{page}}</strong><span>/ {{totalPages}}</span></span><button class="pager-button pager-button--next" :disabled="page>=totalPages || loading" aria-label="下一页" @click="nextPage"><span>下一页</span><ChevronRight aria-hidden="true"/></button></nav>
<nav v-if="totalPages > 1 && (activeView!=='today' || !todaySectionCollapse.tasks)" class="pager" aria-label="任务分页"><button class="pager-button pager-button--previous" :disabled="page<=1 || loading" aria-label="上一页" @click="previousPage"><ChevronLeft aria-hidden="true"/><span>上一页</span></button><span class="pager-status" aria-live="polite"><strong>{{page}} / {{totalPages}}</strong><span>共 {{ totalTasks }} 项</span></span><button class="pager-button pager-button--next" :disabled="page>=totalPages || loading" aria-label="下一页" @click="nextPage"><span>下一页</span><ChevronRight aria-hidden="true"/></button></nav>
<div v-if="activeView==='today'" class="today-habits-section today-section-anchor">
<button id="today-habits-heading" class="today-section-toggle" type="button" :aria-expanded="!todaySectionCollapse.habits" aria-controls="today-habits" @click="toggleTodaySection('habits')"><span class="today-section-title">习惯</span><span class="today-section-summary">{{todayHabitTotal}}</span><span class="today-section-chevron" aria-hidden="true">{{ todaySectionCollapse.habits ? '' : '⌄' }}</span></button>
<div v-show="!todaySectionCollapse.habits" id="today-habits" role="region" aria-labelledby="today-habits-heading">
File diff suppressed because one or more lines are too long
+7 -8
View File
@@ -80,24 +80,23 @@ describe('approved five-detail polish', () => {
expect(app).toContain('<span id="task-list-title" class="list-section-title">任务</span>')
expect(app).toContain("v-if=\"activeView==='tasks' && taskReorderAvailable\"")
expect(app).toContain('<span class="list-section-count">{{ totalTasks }}</span>')
expect(app).toContain("v-if=\"activeView==='tasks' && totalPages > 1\" class=\"list-page-meta\"")
expect(app).not.toContain("v-if=\"activeView==='tasks' && totalPages > 1\" class=\"list-page-meta\"")
const taskListEnd = app.indexOf('</section>', app.indexOf('class=\"task-list plain-list\"'))
expect(app.indexOf('class=\"list-page-meta\"')).toBeGreaterThan(taskListEnd)
expect(app.indexOf('class=\"pager\"')).toBeGreaterThan(taskListEnd)
expect(app).toContain('ref="taskListElement"')
expect(app).toContain("totalPages > 1 && (activeView!=='today' || !todaySectionCollapse.tasks)")
expect(app).toContain("taskListElement.value?.scrollIntoView({ block: 'start' })")
expect(app).toContain('class="list-page-meta" aria-live="polite"')
expect(app).not.toContain('class="list-page-meta" aria-live="polite"')
expect(app).toContain('<nav v-if="totalPages > 1 && (activeView!==\'today\' || !todaySectionCollapse.tasks)" class="pager" aria-label="任务分页">')
expect(app).toContain('class="pager-button pager-button--previous"')
expect(app).toContain('<ChevronLeft aria-hidden="true"/><span>上一页</span>')
expect(app).toContain('<span class="pager-status" aria-live="polite"><strong>{{page}}</strong><span>/ {{totalPages}}</span></span>')
expect(app).toContain('<span class="pager-status" aria-live="polite"><strong>{{page}} / {{totalPages}}</strong><span> {{ totalTasks }} 项</span></span>')
expect(app).toContain('class="pager-button pager-button--next"')
expect(app).toContain('<span>下一页</span><ChevronRight aria-hidden="true"/>')
expect(css).toContain('.pager{min-height:52px;padding:4px;display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:4px;margin:0 0 14px;border:1px solid #e8e0d5;border-radius:15px;background:#f7f1e7;box-shadow:inset 0 1px 0 rgba(255,255,255,.88),0 4px 12px rgba(92,67,40,.05)}')
expect(css).toContain('.pager-button{min-width:0;min-height:44px;padding:0 14px;display:flex;align-items:center;justify-content:center;gap:7px;border:1px solid transparent;border-radius:11px;background:#fffdf8;color:#514a40;font-size:13px;font-weight:650;box-shadow:inset 0 1px 0 #fff,0 1px 3px rgba(92,67,40,.08);transition:transform .14s ease,border-color .14s ease,background-color .14s ease,color .14s ease,box-shadow .14s ease}')
expect(css).toContain('.pager-status{min-width:0;width:62px;display:flex;align-items:baseline;justify-content:center;gap:4px;color:var(--muted);font-size:12px;font-variant-numeric:tabular-nums}')
expect(css).toContain('@media(max-width:390px){.pager-button{padding:0 10px}.pager{grid-template-columns:minmax(0,1fr) 56px minmax(0,1fr)}.pager-status{width:56px}}')
expect(css).toContain('.pager{min-height:56px;display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);align-items:center;gap:8px;margin:8px 0 14px;border-top:1px solid #e8e0d5;background:transparent}')
expect(css).toContain('.pager-button{min-width:0;min-height:44px;padding:0 8px;display:flex;align-items:center;justify-content:center;gap:6px;border:0;border-radius:9px;background:transparent;color:#b7421e;font-size:13px;font-weight:650;box-shadow:none;transition:transform .14s ease,background-color .14s ease,color .14s ease}')
expect(css).toContain('.pager-status{min-width:72px;display:grid;justify-items:center;gap:1px;color:var(--muted);font-size:11px;font-variant-numeric:tabular-nums}')
expect(css).toContain('@media(max-width:390px){.pager-button{padding:0 4px}.pager{grid-template-columns:minmax(0,1fr) 72px minmax(0,1fr);gap:2px}}')
expect(app).toContain("if (activeView.value === 'upcoming') { openParams.set('due_from', isoAtLocalDayOffset(0)); openParams.set('due_to', isoAtLocalDayOffset(8)) }")
expect(app).toContain("new Date(task.due_at) >= startOfLocalDay(0) && new Date(task.due_at) < startOfLocalDay(8)")
expect(app).not.toContain('class="list-search-clear"')