let bleName: string | null = null let bleMac: string | null = null // 保存蓝牙名字 export function setName(name: string) { bleName = name uni.setStorageSync('bleName', name) } // 读取蓝牙名字 export function getName(): string | null { if (bleName != null) { return bleName } const t = uni.getStorageSync('bleName') as string | null bleName = t ?? null return bleName } // 保存蓝牙mac export function setMac(mac: string) { bleMac = mac uni.setStorageSync('bleMac', mac) } // 读取蓝牙mac export function getMac(): string | null { if (bleMac != null) { return bleMac } const t = uni.getStorageSync('bleMac') as string | null bleMac = t ?? null return bleMac } export function clearAllData() { bleName = null bleMac = null uni.removeStorageSync('bleName') uni.removeStorageSync('bleMac') }