修改mqtt连接方式
This commit is contained in:
29
src/App.vue
29
src/App.vue
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user