From 74591d4da2c351870eb3bdd0d379afec9fbe92eb Mon Sep 17 00:00:00 2001 From: Guoguo Date: Mon, 29 Jun 2026 04:02:16 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20audit=20fixes=20=E2=80=94=20dedupe=20run?= =?UTF-8?q?=5Fstate=20logs,=20stop=20device=20on=20scan=20exit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Only log run_state when value changes (avoid flooding console) - Send stopTreatment on unload if scan is in progress (stop device LEDs) --- miniprogram/pages/auto-scan/auto-scan.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/miniprogram/pages/auto-scan/auto-scan.js b/miniprogram/pages/auto-scan/auto-scan.js index db7f9f1..d0deea6 100644 --- a/miniprogram/pages/auto-scan/auto-scan.js +++ b/miniprogram/pages/auto-scan/auto-scan.js @@ -72,9 +72,13 @@ Page({ } ble.on('adc', self._onAdc) + self._lastRunState = -1 self._onRunState = function (data) { 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) { self._seenScanning = true } @@ -158,6 +162,9 @@ Page({ }, onUnload: function () { + if (this.data.state === 'scanning' && !this._completed) { + ble.stopTreatment().catch(function () {}) + } this._cleanup() } })