a0f6b7c67d
思考展开复用安全Markdown渲染,折叠显示浅色单行纯文本预览与右侧箭头。 共享过程摘要组件,执行过程按真实操作数显示统计并保留各组独立计时。 工具、整轮、生成任务和策划耗时统一为中文时分秒格式。 补齐格式与Markdown回归、更新已有界面断言并验证窄屏键盘操作。
27 lines
889 B
TypeScript
27 lines
889 B
TypeScript
/**
|
|
* 毫秒耗时的统一显示:5.2秒 / 2分05.2秒 / 1时02分05.2秒。
|
|
* 保留十分之一秒,先整体舍入再拆单位,避免 60.0 秒或 60 分溢出。
|
|
* 非法或未知耗时返回 null,不能以 0 冒充已测得结果。
|
|
*/
|
|
export function formatElapsedDuration(
|
|
milliseconds: number | null | undefined,
|
|
): string | null {
|
|
if (
|
|
milliseconds == null ||
|
|
!Number.isFinite(milliseconds) ||
|
|
milliseconds < 0
|
|
) {
|
|
return null;
|
|
}
|
|
const tenths = Math.round(milliseconds / 100);
|
|
const hours = Math.floor(tenths / 36_000);
|
|
const minutes = Math.floor((tenths % 36_000) / 600);
|
|
const seconds = ((tenths % 600) / 10).toFixed(1);
|
|
if (hours > 0) {
|
|
return `${hours}时${String(minutes).padStart(2, '0')}分${seconds.padStart(4, '0')}秒`;
|
|
}
|
|
return minutes > 0
|
|
? `${minutes}分${seconds.padStart(4, '0')}秒`
|
|
: `${seconds}秒`;
|
|
}
|