143afd59
杨鑫
打印,标签
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import {
getBluetoothConnection,
getPrinterType,
isBuiltinConnected,
} from './printerConnection'
/** 同步:是否已选择并保存了可用的打印机连接(蓝牙已配对写入 storage / 或内置) */
export function isPrinterReadySync(): boolean {
const type = getPrinterType()
if (type === 'builtin') return isBuiltinConnected()
if (type === 'bluetooth') return !!getBluetoothConnection()
return false
}
/**
|
143afd59
杨鑫
打印,标签
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
*/
export function checkBluetoothAdapterAvailable(): Promise<boolean> {
return new Promise((resolve) => {
// #ifdef APP-PLUS
uni.getBluetoothAdapterState({
success: (res) => {
resolve(res.available === true)
},
fail: () => {
resolve(false)
},
})
// #endif
// #ifndef APP-PLUS
resolve(false)
// #endif
})
}
|