feat: 补齐今日视图待办组、卡片键盘操作、深色模式
今日视图 - 补上「待办」组。此前只收 逾期 / 今天到期 / 进行中,导致待办列里没设 截止日期的任务在今日视图里完全消失 —— 用户明明有一堆事没做,却看到 「今天没有待办事项」。现在只要任务未完成且未归档,就必定出现在某个 分组里(归属优先级:逾期 > 今天到期 > 进行中 > 待办)。 - 统计卡片改为与分组一一对应(逾期 / 今天到期 / 进行中 / 本周完成), 不再用「今日待办」这种把四组混在一起、与列表长度对不上的指标。 键盘操作(可访问性) - 卡片可聚焦(Tab / 点击),← → 换列、↑ ↓ 列内调序、Enter 打开详情。 - 换列时追加到目标列末尾:用全量长度而不是可见下标,筛选态下也安全; 列内调序要求该列渲染的是全量,否则禁用(与拖拽的规则一致)。 - 移动后手动恢复焦点 —— 卡片跨列会被重建,不恢复的话连续按键会失效。 深色模式 - 三态:跟随系统 / 浅色 / 深色,选择持久化到 localStorage。 - index.html 内联脚本在首帧之前应用主题,避免深色下闪白。 - 用 @custom-variant dark 做 class 控制(而不是纯 media query), 才能支持「强制浅色」;html 的 color-scheme 让原生控件与滚动条跟随。 验证:单元测试 480 个、端到端测试 25 个全部通过,lint 与构建无错误。 截图脚本新增深色与移动端深色两组,便于后续对照。
This commit is contained in:
@@ -148,3 +148,57 @@ describe('交互', () => {
|
||||
expect(mountCard().find('article').classes().join(' ')).toContain('cursor-pointer')
|
||||
})
|
||||
})
|
||||
|
||||
describe('TaskCard 键盘操作', () => {
|
||||
it('卡片可聚焦', () => {
|
||||
expect(mountCard().find('article').attributes('tabindex')).toBe('0')
|
||||
})
|
||||
|
||||
it('方向键 emit keymove 并带上方向', async () => {
|
||||
const wrapper = mountCard({ id: 'task-1' })
|
||||
const article = wrapper.find('article')
|
||||
|
||||
await article.trigger('keydown', { key: 'ArrowLeft' })
|
||||
await article.trigger('keydown', { key: 'ArrowRight' })
|
||||
await article.trigger('keydown', { key: 'ArrowUp' })
|
||||
await article.trigger('keydown', { key: 'ArrowDown' })
|
||||
|
||||
expect(wrapper.emitted('keymove')).toEqual([
|
||||
[{ id: 'task-1', direction: 'left' }],
|
||||
[{ id: 'task-1', direction: 'right' }],
|
||||
[{ id: 'task-1', direction: 'up' }],
|
||||
[{ id: 'task-1', direction: 'down' }],
|
||||
])
|
||||
})
|
||||
|
||||
it('Enter 与空格都能打开详情', async () => {
|
||||
const wrapper = mountCard({ id: 'task-2' })
|
||||
const article = wrapper.find('article')
|
||||
|
||||
await article.trigger('keydown', { key: 'Enter' })
|
||||
await article.trigger('keydown', { key: ' ' })
|
||||
|
||||
expect(wrapper.emitted('open')).toEqual([['task-2'], ['task-2']])
|
||||
})
|
||||
|
||||
it('其他按键不产生任何事件', async () => {
|
||||
const wrapper = mountCard()
|
||||
const article = wrapper.find('article')
|
||||
|
||||
await article.trigger('keydown', { key: 'a' })
|
||||
await article.trigger('keydown', { key: 'Tab' })
|
||||
|
||||
expect(wrapper.emitted('keymove')).toBeUndefined()
|
||||
expect(wrapper.emitted('open')).toBeUndefined()
|
||||
})
|
||||
|
||||
it('方向键被 preventDefault(避免连带着滚动看板)', async () => {
|
||||
const wrapper = mountCard()
|
||||
const article = wrapper.find('article')
|
||||
|
||||
const event = new KeyboardEvent('keydown', { key: 'ArrowDown', cancelable: true })
|
||||
article.element.dispatchEvent(event)
|
||||
|
||||
expect(event.defaultPrevented).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user