fix: 实际耗时改为精确时间戳计算(精确到0.5h)

之前用日期+工作日×8h 计算耗时太粗糙,现改为:
- DevTask startDate/completedAt 使用完整 ISO 时间戳(含时分秒)
- TestCase startedAt/completedAt 同上
- 耗时 = (endTimestamp - startTimestamp) / 3600000,精确到0.5h
- 详情抽屉显示精确到分钟的时间(YYYY-MM-DD HH:mm)

例如:08:00 开始,10:30 提测,耗时 2.5h(不再是8h)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Script Generator
2026-06-12 16:11:51 +08:00
parent 664330fe11
commit c86e87f95b
5 changed files with 17 additions and 26 deletions

View File

@@ -74,14 +74,12 @@ export const useTestCaseStore = create<TestCaseState>((set, get) => ({
if (!canTcTransition(tc.status, to)) {
return { ok: false, message: `不允许从「${tc.status}」流转到「${to}` };
}
const today = new Date().toISOString().slice(0, 10);
const now = new Date().toISOString();
const patch: Partial<TestCase> = { status: to };
// 开始执行时间
if (to === 'running' && !tc.startedAt) patch.startedAt = today;
// 执行完成时间(通过/失败/阻塞都算执行完成)
if (to === 'passed' || to === 'failed' || to === 'blocked') patch.completedAt = today;
if (to === 'running' && !tc.startedAt) patch.startedAt = now;
if (to === 'passed' || to === 'failed' || to === 'blocked') patch.completedAt = now;
if (to === 'running' || to === 'passed' || to === 'failed' || to === 'blocked') {
patch.executedAt = today;
patch.executedAt = now;
}
// 回退到执行中时清除完成时间
if (to === 'running') { patch.failReason = undefined; patch.blockReason = undefined; patch.completedAt = undefined; }