fix: audit fixes — dedupe run_state logs, stop device on scan exit

- Only log run_state when value changes (avoid flooding console)
- Send stopTreatment on unload if scan is in progress (stop device LEDs)
这个提交包含在:
Guoguo
2026-06-29 04:02:16 -07:00
父节点 f5cd882986
当前提交 74591d4da2
+8 -1
查看文件
@@ -72,9 +72,13 @@ Page({
} }
ble.on('adc', self._onAdc) ble.on('adc', self._onAdc)
self._lastRunState = -1
self._onRunState = function (data) { self._onRunState = function (data) {
if (self._completed) return if (self._completed) return
console.log('[SCAN] run_state:', data.run_state) if (data.run_state !== self._lastRunState) {
console.log('[SCAN] run_state:', data.run_state)
self._lastRunState = data.run_state
}
if (data.run_state === 0x01) { if (data.run_state === 0x01) {
self._seenScanning = true self._seenScanning = true
} }
@@ -158,6 +162,9 @@ Page({
}, },
onUnload: function () { onUnload: function () {
if (this.data.state === 'scanning' && !this._completed) {
ble.stopTreatment().catch(function () {})
}
this._cleanup() this._cleanup()
} }
}) })