修改mqtt连接方式

This commit is contained in:
GGJ
2024-12-30 10:07:26 +08:00
parent 0f57e4b746
commit 6a06652532
19 changed files with 173 additions and 93 deletions

View File

@@ -7,15 +7,30 @@
<script lang="ts" setup>
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import useSetTheme from '@/utils/setTheme'
import { provide, getCurrentInstance } from 'vue'
import { provide, onMounted, ref } from 'vue'
//线上mqtt
// 27服务器项目使用的MQTT:ws://pqmcn.com:8073/mqtt
// 102服务器项目使用的MQTT:wss://pqmcn.com:8087/mqtt
// let buildUrl = 'wss://pqmcn.com:8087/mqtt'//102
let buildUrl = 'ws://pqmcn.com:8073/mqtt'//27
let buildUrl = 'wss://pqmcn.com:8087/mqtt'//102
// let buildUrl = 'ws://pqmcn.com:8073/mqtt'//27
// 从 Nginx 获取 MQTT URL
const fetchMqttUrl = async () => {
const response = await fetch('/')
const mqttUrl = response.headers.get('X-MQTT-URL')
window.localStorage.setItem('MQTTURL', mqttUrl || buildUrl)
}
//本地mqtt
let devUrl = 'ws://192.168.1.24:8085/mqtt'
provide('MQTTURL', buildUrl)
// let devUrl = 'ws://192.168.1.24:8085/mqtt'
onMounted(() => {
fetchMqttUrl()
})
// provide('MQTTURL', buildUrl.value)
useSetTheme()
</script>