Skip to content

修改计时小数点后的样式#195

Open
Leonhardt92 wants to merge 2 commits into
ZToolsCenter:mainfrom
Leonhardt92:patch-2
Open

修改计时小数点后的样式#195
Leonhardt92 wants to merge 2 commits into
ZToolsCenter:mainfrom
Leonhardt92:patch-2

Conversation

@Leonhardt92
Copy link
Copy Markdown

No description provided.

Added displayTick computed property to show tenths of a second.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant