微调
This commit is contained in:
@@ -90,7 +90,7 @@ const init = async () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('MQTT 初始化失败:', error)
|
// console.error('MQTT 初始化失败:', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|||||||
@@ -50,15 +50,17 @@ class MQTT {
|
|||||||
if (this.client) {
|
if (this.client) {
|
||||||
throw new Error('MQTT 客户端已初始化')
|
throw new Error('MQTT 客户端已初始化')
|
||||||
}
|
}
|
||||||
|
const mqttUrl = localStorage.getItem('MqttUrl')
|
||||||
|
console.log('MQTT URL:', mqttUrl)
|
||||||
|
if (!mqttUrl || mqttUrl === 'null') {
|
||||||
|
return Promise.resolve()
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
// const mqttUrl =
|
// const mqttUrl =
|
||||||
// localStorage.getItem('MqttUrl') == 'null'
|
// localStorage.getItem('MqttUrl') == 'null'
|
||||||
// ? 'ws://192.168.1.68:8083/mqtt'
|
// ? 'ws://192.168.1.68:8083/mqtt'
|
||||||
// : localStorage.getItem('MqttUrl')
|
// : localStorage.getItem('MqttUrl')
|
||||||
const mqttUrl = localStorage.getItem('MqttUrl')
|
|
||||||
console.log('MQTT URL:', mqttUrl)
|
|
||||||
if (mqttUrl == 'null' || mqttUrl == null) return
|
|
||||||
this.client = mqtt.connect(mqttUrl, this.defaultOptions as IClientOptions)
|
this.client = mqtt.connect(mqttUrl, this.defaultOptions as IClientOptions)
|
||||||
this.setupEventListeners()
|
this.setupEventListeners()
|
||||||
|
|
||||||
@@ -79,12 +81,12 @@ class MQTT {
|
|||||||
|
|
||||||
this.client?.on('error', error => {
|
this.client?.on('error', error => {
|
||||||
clearTimeout(timeout)
|
clearTimeout(timeout)
|
||||||
console.error('MQTT 连接错误:', error)
|
console.log('MQTT 连接错误:', error)
|
||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('初始化 MQTT 失败:', error)
|
// console.log('初始化 MQTT 失败:', error)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +135,7 @@ class MQTT {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.client?.subscribe(this.topic, { qos: this.defaultOptions.qos, ...subscribeOptions }, error => {
|
this.client?.subscribe(this.topic, { qos: this.defaultOptions.qos, ...subscribeOptions }, error => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('订阅失败:', error)
|
console.log('订阅失败:', error)
|
||||||
reject(error)
|
reject(error)
|
||||||
} else {
|
} else {
|
||||||
console.log('订阅成功')
|
console.log('订阅成功')
|
||||||
@@ -155,7 +157,7 @@ class MQTT {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.client?.unsubscribe(this.topic, error => {
|
this.client?.unsubscribe(this.topic, error => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('取消订阅失败:', error)
|
console.log('取消订阅失败:', error)
|
||||||
reject(error)
|
reject(error)
|
||||||
} else {
|
} else {
|
||||||
console.log('取消订阅成功')
|
console.log('取消订阅成功')
|
||||||
@@ -190,7 +192,7 @@ class MQTT {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.client?.publish(this.topic, message, { qos: this.defaultOptions.qos, ...options }, error => {
|
this.client?.publish(this.topic, message, { qos: this.defaultOptions.qos, ...options }, error => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('消息发布失败:', error)
|
console.log('消息发布失败:', error)
|
||||||
reject(error)
|
reject(error)
|
||||||
} else {
|
} else {
|
||||||
console.log('消息发布成功')
|
console.log('消息发布成功')
|
||||||
|
|||||||
@@ -1740,7 +1740,7 @@ const optionarr = ref([
|
|||||||
])
|
])
|
||||||
/**母线类型 */
|
/**母线类型 */
|
||||||
const busBarType = ref([
|
const busBarType = ref([
|
||||||
{ name: '实际母线', value: 1 },
|
{ name: '真实母线', value: 1 },
|
||||||
{ name: '虚拟母线', value: 0 }
|
{ name: '虚拟母线', value: 0 }
|
||||||
])
|
])
|
||||||
const bigList: any = ref([])
|
const bigList: any = ref([])
|
||||||
@@ -1811,7 +1811,7 @@ const busBarDetail = ref({
|
|||||||
/**电压等级 */
|
/**电压等级 */
|
||||||
scale: '',
|
scale: '',
|
||||||
/**母线类型 */
|
/**母线类型 */
|
||||||
model: 0,
|
model: 1,
|
||||||
/**母线id */
|
/**母线id */
|
||||||
subvIndex: '',
|
subvIndex: '',
|
||||||
/**监测点 */
|
/**监测点 */
|
||||||
|
|||||||
@@ -467,8 +467,7 @@ const makeUpSubmit = () => {
|
|||||||
reCallEndTime: timeData.value[1],
|
reCallEndTime: timeData.value[1],
|
||||||
reCallStartTime: timeData.value[0]
|
reCallStartTime: timeData.value[0]
|
||||||
}
|
}
|
||||||
console.log('2222',form)
|
|
||||||
return
|
|
||||||
socket(form)
|
socket(form)
|
||||||
timePopUp.value = false
|
timePopUp.value = false
|
||||||
logPopUp.value = true
|
logPopUp.value = true
|
||||||
|
|||||||
Reference in New Issue
Block a user