fix(admin): dashboard 待办卡片点击导航去重与防抖
Some checks failed
CI / check (pull_request) Failing after 3m19s
Some checks failed
CI / check (pull_request) Failing after 3m19s
- 同一目标路径不再重复 navigate,避免历史记录堆叠 - 400ms 冷却期内忽略重复/幽灵点击,防止来回跳转 - 新增 shouldNavigateTodoCard 守卫单元测试
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { shouldNavigateTodoCard } from './DashboardTodoCards';
|
||||
|
||||
describe('DashboardTodoCards 点击导航守卫', () => {
|
||||
it('目标路径与当前路径不同且冷却已过时允许导航', () => {
|
||||
expect(shouldNavigateTodoCard('/dashboard', '/attendance', 1000, 1600)).toBe(true);
|
||||
});
|
||||
|
||||
it('目标路径与当前路径相同时不允许导航', () => {
|
||||
expect(shouldNavigateTodoCard('/attendance', '/attendance', 1000, 1600)).toBe(false);
|
||||
});
|
||||
|
||||
it('冷却期内忽略重复点击,防止产生多条历史记录', () => {
|
||||
expect(shouldNavigateTodoCard('/dashboard', '/attendance', 1000, 1300)).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user