feat: 开发任务时间字段重构 + 双口径耗时 + 搜索 + 性能优化

核心变更:
- DevTask 字段重构:startDate/dueDate/estimateHours/actualHours 替换为 expectedStartAt/expectedEndAt/actualStartAt/actualEndAt(含时分),预计/实际工时按工作时段(9:00-12:00 + 13:00-18:00)派生计算
- 状态机自动化:到点自动切开发中、未到可手动开干、超期需填延后原因
- 新建 lib/work-hours.ts:calcWorkHours(工作时段过滤)、formatWorkHours(X h(Y 天))、calcTwoMetrics(日历/人力双口径)
- 新建 lib/dev-task-transitions.ts:状态切换守卫
- 三个 Tab 顶部统计:开发任务(预/日历/人力)、测试用例 / Bug(日历 / 人力);版本概览总人天投入改双行(日历总耗时 / 人力总投入)
- 三个 Tab 加搜索框:300ms debounce + 标题/编号模糊匹配
- 性能优化:requirementIds/categories/requirements/testCases 转 Map/Set 索引、Row 组件 React.memo
- 全局耗时显示统一带天数换算:8h(1天)、11h(1.4天)

新增文件: SearchInput.tsx, useDebouncedValue.ts, work-hours.ts, dev-task-transitions.ts, 设计文档

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Script Generator
2026-06-16 17:44:59 +08:00
parent 4ac0dab4c5
commit 1f5bed0c79
25 changed files with 1192 additions and 221 deletions

View File

@@ -0,0 +1,48 @@
'use client';
import { Search, X } from 'lucide-react';
interface Props {
value: string;
onChange: (v: string) => void;
placeholder?: string;
className?: string;
}
/**
* 列表搜索框(标题 + 编号模糊匹配,外部需配合 useDebouncedValue 防抖)
*/
export function SearchInput({ value, onChange, placeholder = '搜索标题或编号', className = '' }: Props) {
return (
<div className={`relative inline-flex items-center ${className}`}>
<Search className="absolute left-2 h-3 w-3 text-[var(--ink-muted)] pointer-events-none" />
<input
type="text"
value={value}
onChange={(e) => onChange(e.target.value)}
placeholder={placeholder}
className="h-6 w-72 pl-7 pr-6 rounded border border-[var(--line)] bg-[var(--bg-card)] text-[11px] text-[var(--ink)] focus:border-[var(--accent)] focus:outline-none"
/>
{value && (
<button
onClick={() => onChange('')}
className="absolute right-1 p-0.5 rounded hover:bg-[var(--bg-subtle)]"
title="清除"
>
<X className="h-3 w-3 text-[var(--ink-muted)]" />
</button>
)}
</div>
);
}
/**
* 标题 + 编号模糊匹配case-insensitive
*/
export function matchTitleOrNo(item: { title: string; no?: string }, keyword: string): boolean {
if (!keyword) return true;
const k = keyword.trim().toLowerCase();
if (!k) return true;
if (item.title.toLowerCase().includes(k)) return true;
if (item.no && item.no.toLowerCase().includes(k)) return true;
return false;
}