From a254039d5ed07df8cd62b132405042955f56f27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E9=B9=8F?= Date: Wed, 13 Nov 2024 14:36:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E6=B0=B4=E7=94=B5?= =?UTF-8?q?=E5=85=85=E5=80=BC=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- basic.js | 15 +++------------ starCloud.js | 6 ++++++ 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/basic.js b/basic.js index bc745bf..37ced86 100644 --- a/basic.js +++ b/basic.js @@ -257,21 +257,12 @@ function openBluetoothAdapter() { } // 关闭蓝牙模块 -function closeBluetoothAdapter() { - return new Promise(resolve => { - uni.closeBluetoothAdapter({ - success() { - resolve(Result.Success) - }, - async fail(err) { - resolve(await handleError(err)) - } - }) - }) +export function closeBluetoothAdapter() { + uni.closeBluetoothAdapter() } // 移除蓝牙适配器的全部监听 -function offBluetoothAdapterStateChange() { +export function offBluetoothAdapterStateChange() { uni.offBluetoothAdapterStateChange() } diff --git a/starCloud.js b/starCloud.js index 0fc6bb2..fbfd96b 100644 --- a/starCloud.js +++ b/starCloud.js @@ -18,8 +18,10 @@ import { import { getStorage, removeStorage, setStorage } from '@/starCloud/storage' import { closeBLEConnection, + closeBluetoothAdapter, createBLEConnection, getBluetoothDevices, + offBluetoothAdapterStateChange, onBLECharacteristicValueChange, Result, searchAndConnectDevice, @@ -659,6 +661,10 @@ export const useStarCloudStore = defineStore('starCloud', { if (addUserResult.code !== Result.Success.code) { return addUserResult } + + offBluetoothAdapterStateChange() + closeBluetoothAdapter() + const params = { lockAlias: this.lockInfo.bluetooth.bluetoothDeviceName, lockInfo: {