diff --git a/src/utils/mqtt.ts b/src/utils/mqtt.ts index 6d0d528..cfac351 100644 --- a/src/utils/mqtt.ts +++ b/src/utils/mqtt.ts @@ -18,6 +18,8 @@ export interface SubscribeOptions { const getMqttConfig = () => { // 检测当前页面协议(http: 或 https:) const isHttps = window.location.protocol === 'https:'; + console.log(isHttps,'检测环境'); + return { // 自动切换协议:https页面用wss,http页面用ws protocol: isHttps ? 'wss' : 'ws', @@ -57,8 +59,15 @@ export function useMqtt() { error.value = null; try { + // 打印当前使用的配置(方便调试) + console.log('当前MQTT连接配置:', { + protocol: MQTT_CONFIG.protocol, + host: MQTT_CONFIG.host, + port: MQTT_CONFIG.port, + clientId: MQTT_CONFIG.clientId + }); client = new Paho.Client( - MQTT_CONFIG.host, + MQTT_CONFIG.host, MQTT_CONFIG.port, MQTT_CONFIG.clientId ); diff --git a/src/views/equipmentManagement/devices/index.vue b/src/views/equipmentManagement/devices/index.vue index 859fa42..3077778 100644 --- a/src/views/equipmentManagement/devices/index.vue +++ b/src/views/equipmentManagement/devices/index.vue @@ -737,11 +737,12 @@ const submitForm = async () => { // 处理图片字段 if (form.value.image instanceof File) { formData.append('file', form.value.image); - } else if (form.value.image && typeof form.value.image === 'string') { - // 如果是URL且需要转换为二进制 - const blob = await urlToBlob(form.value.image); - formData.append('file', blob, 'image.jpg'); // 添加文件名 } + // else if (form.value.image && typeof form.value.image === 'string') { + // // 如果是URL且需要转换为二进制 + // const blob = await urlToBlob(form.value.image); + // formData.append('file', blob, 'image.jpg'); // 添加文件名 + // } // 添加其他必要字段 const fields = ['id', 'deviceName', 'deviceType', 'remark']; fields.forEach((key) => {