fix: 调研/产品/UI 实际耗时改为精确时间戳显示和计算

- PlanTab 自动进入"进行中"时调用 onUpdate 记录 actualStartAt
- 显示实际开始时间和完成时间(精确到分钟)
- calcPlanDuration 改为用时间差计算小时数(精确到0.5h)
- formatDuration 显示小时而非天数

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Script Generator
2026-06-12 16:32:50 +08:00
parent da1f98968b
commit 7af9206bec
2 changed files with 22 additions and 12 deletions

View File

@@ -48,12 +48,14 @@ export function calcPlanDuration(start: string, end: string): { days: number; ho
const s = new Date(start).getTime();
const e = new Date(end).getTime();
if (isNaN(s) || isNaN(e) || e < s) return { days: 0, hours: 0 };
const diff = Math.ceil((e - s) / (1000 * 60 * 60 * 24));
const totalDays = Math.max(1, diff); // 当天开始当天结束至少1天
return { days: totalDays, hours: totalDays * 8 };
const diffHours = (e - s) / (1000 * 60 * 60);
const hours = Math.round(diffHours * 2) / 2; // 精确到0.5h
const days = Math.ceil(diffHours / 24);
return { days, hours };
}
export function formatDuration(days: number, _hours: number): string {
export function formatDuration(days: number, hours: number): string {
if (hours > 0) return `${hours}h`;
if (days === 0) return '0天';
return `${days}`;
}