step: migrate to vue.js

This commit is contained in:
2026-06-27 14:16:26 +02:00
parent e1a32ecd01
commit 1da5c4fefc
17 changed files with 865 additions and 415 deletions
+31
View File
@@ -0,0 +1,31 @@
import mqtt from 'mqtt'
const mqttBrokerHost = '91.99.29.8'
const mqttBrokerPort = 9001
const mqttBrokerPath = '/mqtt'
const mqttUseTls = false
const mqttTopic = 'king-arthur/page/startup'
const mqttMessage = 'start-hit'
let client: any = null
export function getMqttClient(): any {
return client
}
export function publishStartHit(): void {
const protocol = mqttUseTls ? 'wss' : 'ws'
const brokerUrl = `${protocol}://${mqttBrokerHost}:${mqttBrokerPort}${mqttBrokerPath}`
const tempClient = mqtt.connect(brokerUrl)
tempClient.on('connect', () => {
tempClient.publish(mqttTopic, mqttMessage, { qos: 1 }, () => {
tempClient.end()
})
})
tempClient.on('error', (error: any) => {
console.error('MQTT publish failed:', error)
tempClient.end(true)
})
}