1
0
forked from dyf/APP

添加102联机记录

This commit is contained in:
liub
2026-03-05 10:06:37 +08:00
parent aa87a1a78f
commit c1c7d4491b
43 changed files with 4732 additions and 745 deletions

View File

@ -281,7 +281,36 @@ class MqttClient {
}
}
publish(topic, message,retained) {
async publish(topic, message,retained) {
let getLan=()=>{
return new Promise((succ,error)=>{
uni.getNetworkType({
success: (res) => {
let networkType = res.networkType;
// 判断网络是否连接
if (networkType === 'none') {
console.error('无网络连接')
succ(false);
} else {
succ(true);
}
},
fail: (err) => {
console.error('获取网络状态失败:', err);
succ(false);
}
});
});
}
let flag=await getLan();
if(!flag){
return false;
}
if (this.client && this.client.isConnected()) {
const mqttMessage = new Paho.Message(message);
mqttMessage.destinationName = topic;