feat: 更新manifest.json和蓝牙逻辑,优化蓝牙未开启提示,增强用户交互体验

This commit is contained in:
fanpeng 2025-07-16 15:38:47 +08:00
parent 08b0121560
commit 406466d792
2 changed files with 142 additions and 126 deletions

View File

@ -34,6 +34,10 @@
}, },
"vueVersion" : "3", "vueVersion" : "3",
"app-plus" : { "app-plus" : {
"optimization" : {
"subPackages" : true
},
"runmode" : "liberate",
"distribute" : { "distribute" : {
"icons" : { "icons" : {
"android" : { "android" : {
@ -106,10 +110,18 @@
} }
}, },
"modules" : { "modules" : {
"Bluetooth": {}, "Bluetooth" : {
"VideoPlayer": {}, "description" : "低功耗蓝牙"
"Camera": {}, },
"Record": {} "VideoPlayer" : {
"description" : "视频播放"
},
"Camera" : {
"description" : "相机和相册"
},
"Record" : {
"description" : "录音"
}
}, },
"splashscreen" : { "splashscreen" : {
"waiting" : false "waiting" : false

View File

@ -900,20 +900,24 @@ export const useBluetoothStore = defineStore('ble', {
}) })
// #endif // #endif
// #ifdef APP-PLUS // #ifdef APP-PLUS
const systemInfo = uni.getSystemInfoSync()
if (systemInfo.platform === 'android') {
const main = plus.android.runtimeMainActivity()
const Intent = plus.android.importClass('android.content.Intent')
const BluetoothAdapter = plus.android.importClass('android.bluetooth.BluetoothAdapter')
const intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
main.startActivity(intent)
} else if (systemInfo.platform === 'ios') {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '蓝牙尚未打开,请先打开蓝牙', content: '蓝牙尚未打开,请先打开蓝牙',
showCancel: false showCancel: false,
}) success(res) {
if (res.confirm) {
// #ifdef APP-ANDROID
const main = plus.android.runtimeMainActivity()
const Intent = plus.android.importClass('android.content.Intent')
const BluetoothAdapter = plus.android.importClass(
'android.bluetooth.BluetoothAdapter'
)
const intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE)
main.startActivity(intent)
// #endif
} }
}
})
// #endif // #endif
} }
} else if (this.bluetoothStatus === 2 || this.bluetoothStatus === 3) { } else if (this.bluetoothStatus === 2 || this.bluetoothStatus === 3) {