refactor: 移除重做/应用按钮, 自动应用更改, 删除死代码, 修复性能问题
UI 变更: - 移除重做按钮及 redo/canRedo/redoStack 相关逻辑 (useCalendar, HeaderBar) - 移除应用更改按钮, EventDetail 改为 watch form 自动应用 (deep watch) - 用 syncing 标志防止 syncForm 回写时触发自动应用的循环 死代码清理: - weekday.js: 移除未使用的 BYDAY_TO_INDEX 和 dowLabel - date.js: 移除未使用的 toHHMM - App.vue: 移除未使用的 .empty CSS - DropZone.vue: 移除空的 .icon 容器及 CSS - test/weekday.test.js: 移除对应死代码的 2 个测试用例 性能修复: - WeekPreview: layoutEvents 从模板内联调用改为 computed (laidOutByDate), 避免每次渲染重新计算布局 - MonthPreview: occByDate 过滤为仅网格内 42 天, 避免展开全部 occurrence 代码质量: - useCalendar: prevMonth/nextMonth 合并为 shiftMonth(delta), 消除重复 - WeekPreview/MonthPreview: 移除未使用导入 (toISODate, toDate)
This commit is contained in:
@@ -1,31 +1,21 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { DOW, DOW_EN, BYDAY_TO_INDEX, bydayFromDate, dowLabel } from '../src/lib/weekday.js'
|
||||
import { DOW, DOW_EN, bydayFromDate } from '../src/lib/weekday.js'
|
||||
|
||||
describe('weekday', () => {
|
||||
it('DOW has 7 entries starting Sunday', () => {
|
||||
it('DOW 有 7 项, 首项为周日', () => {
|
||||
expect(DOW).toHaveLength(7)
|
||||
expect(DOW[0]).toBe('周日')
|
||||
expect(DOW[6]).toBe('周六')
|
||||
})
|
||||
|
||||
it('DOW_EN indexed by JS getDay (0=Sunday)', () => {
|
||||
it('DOW_EN 按 JS getDay 索引 (0=周日)', () => {
|
||||
expect(DOW_EN).toEqual(['SU', 'MO', 'TU', 'WE', 'TH', 'FR', 'SA'])
|
||||
})
|
||||
|
||||
it('BYDAY_TO_INDEX maps SU..SA to 0..6', () => {
|
||||
expect(BYDAY_TO_INDEX.SU).toBe(0)
|
||||
expect(BYDAY_TO_INDEX.SA).toBe(6)
|
||||
})
|
||||
|
||||
it('bydayFromDate returns BYDAY code for a Date', () => {
|
||||
// 2026-07-27 is a Monday -> getDay()=1 -> 'MO'
|
||||
it('bydayFromDate 返回 Date 对应的 BYDAY 编码', () => {
|
||||
// 2026-07-27 是周一 -> getDay()=1 -> 'MO'
|
||||
expect(bydayFromDate(new Date(2026, 6, 27))).toBe('MO')
|
||||
// 2026-08-01 is a Saturday -> getDay()=6 -> 'SA'
|
||||
// 2026-08-01 是周六 -> getDay()=6 -> 'SA'
|
||||
expect(bydayFromDate(new Date(2026, 7, 1))).toBe('SA')
|
||||
})
|
||||
|
||||
it('dowLabel returns Chinese label for a Date', () => {
|
||||
expect(dowLabel(new Date(2026, 6, 27))).toBe('周一')
|
||||
expect(dowLabel(new Date(2026, 6, 26))).toBe('周日')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user