fix: 防连点产生重复训练记录 + 补充遗漏的状态重置

- finishTraining 添加 _saving 防重入,避免1.5秒延迟期间连点
- _init 补充 _last30Signaled/_last10Signaled 重置,修复
  多次训练时语音提示丢失的bug

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-06-24 13:20:03 +08:00
parent 1e61ab4fba
commit 6af09e4324
+9
View File
@@ -66,8 +66,11 @@ Page({
// Reset reminder state // Reset reminder state
this._halfwaySignaled = false this._halfwaySignaled = false
this._last30Signaled = false
this._last10Signaled = false
this._lastMinuteAt = 0 this._lastMinuteAt = 0
this._lastCountdown = 0 this._lastCountdown = 0
this._saving = false
this._timer = new Timer({ this._timer = new Timer({
onTick: (tick) => { onTick: (tick) => {
@@ -188,8 +191,14 @@ Page({
}, },
finishTraining() { finishTraining() {
// Guard against double-tap: stop button is still visible during the
// 1.5s navigateBack delay, so a second tap would create a duplicate.
if (this._saving) return
this._saving = true
const elapsed = this._timer.stop() const elapsed = this._timer.stop()
if (elapsed < 3) { if (elapsed < 3) {
this._saving = false
wx.showToast({ title: '训练时间太短', icon: 'none', duration: 1500 }) wx.showToast({ title: '训练时间太短', icon: 'none', duration: 1500 })
setTimeout(() => { wx.navigateBack() }, 1500) setTimeout(() => { wx.navigateBack() }, 1500)
return return