修改计时小数点后的样式#195
Conversation
Added displayTick computed property to show tenths of a second.
There was a problem hiding this comment.
Code Review
This pull request introduces a decisecond display to the timer component by adding a new computed property, displayTick, and updating the UI template and styles. Feedback was provided regarding a potential edge case where negative time values—caused by system clock adjustments—could lead to negative tick values being displayed (e.g., ".-1") due to JavaScript's modulo behavior. A suggestion was made to wrap the value in Math.max(0, ...) to ensure consistent display behavior.
| }) | ||
|
|
||
| const displayTime = computed(() => formatTime(currentDisplayMs.value)) | ||
| const displayTick = computed(() => Math.floor((currentDisplayMs.value % 1000) / 100)) |
There was a problem hiding this comment.
currentDisplayMs.value 在正计时模式下(stopwatch)直接取自 elapsedMs.value。如果系统时钟发生回拨,elapsedMs.value 可能会变为负数。虽然 formatTime 函数内部使用了 Math.max(0, ms) 来处理负值,但这里的 displayTick 计算直接使用了原始值。在 JavaScript 中,负数取模的结果仍为负数(例如 -150 % 1000 为 -150),这会导致界面在极端情况下显示出类似 00:00:00.-1 的异常样式。建议在此处也进行边界检查,确保显示的一致性。
const displayTick = computed(() => Math.floor((Math.max(0, currentDisplayMs.value) % 1000) / 100))
No description provided.