feat:客服

This commit is contained in:
李伊帆
2026-10-16 08:53:45 +08:00
parent e22ebd6bef
commit 03839624ed
42 changed files with 1375 additions and 483 deletions

View File

@@ -1,7 +1,6 @@
import {
findDeviceInBleScan,
isBluetoothApiSupported,
rssiToSignalLevel,
scanBluetoothDevices,
} from '@/utils/bluetooth'
import { sameId } from '@/utils/device-id'
@@ -79,26 +78,28 @@ export async function refreshDevicePresence(
})
void Promise.allSettled(
nextDevices
.filter((device) => device.deviceId && targets.some((item) => sameId(item.deviceId, device.deviceId)))
.map(async (device) => {
const found = findDeviceInBleScan(
{ mac: device.mac, name: device.name },
scanned,
{ strictName: true },
)
const present = !!found
try {
await updateDeviceRuntime({
deviceId: device.deviceId!,
status: present ? '1' : '2',
bluetoothConnected: present ? '1' : '0',
signalLevel: present ? rssiToSignalLevel(found?.RSSI) : '0',
})
} catch (err) {
logPresence('updateRuntime failed', err)
}
}),
targets.map(async (device) => {
const found = findDeviceInBleScan(
{ mac: device.mac, name: device.name },
scanned,
{ strictName: true },
)
const present = !!found
const nextStatus = present ? '1' : '2'
const nextBluetooth = present ? '1' : '0'
if (device.status === nextStatus && device.bluetoothConnected === nextBluetooth) {
return
}
try {
await updateDeviceRuntime({
deviceId: device.deviceId!,
status: nextStatus,
bluetoothConnected: nextBluetooth,
})
} catch (err) {
logPresence('updateRuntime failed', err)
}
}),
)
return nextDevices