<template>
    <el-config-provider :locale="zhCn">
        <router-view></router-view>
    </el-config-provider>
</template>

<script lang="ts" setup>
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import useSetTheme from '@/utils/setTheme'
import { provide, onMounted, ref } from 'vue'
//线上mqtt

// let buildUrl = 'wss://pqmcn.com:8087/mqtt'//102
// let buildUrl = 'ws://pqmcn.com:8073/mqtt' //27
let buildUrl = 'ws://112.4.144.18:38083/mqtt' //27

// 从 Nginx 获取 MQTT URL
const fetchMqttUrl = async () => {
    const response = await fetch('/')
    const mqttUrl = response.headers.get('X-Mqtt-Url')
    const zutai = response.headers.get('X-Mqttzutai-Url')

    window.localStorage.setItem('MQTTURL', mqttUrl || buildUrl)
    window.localStorage.setItem('MQTTZUTAI', zutai || '')
}

//本地mqtt
// let devUrl = 'ws://192.168.1.24:8085/mqtt'

onMounted(() => {
    fetchMqttUrl()
})
// provide('MQTTURL', buildUrl.value)
useSetTheme()
</script>

<style lang="scss">
/* Your SCSS styles here */
</style>
