获取设备列表
This commit is contained in:
parent
2c998e152f
commit
1bb1e72f66
10
src/App.vue
10
src/App.vue
@ -165,10 +165,12 @@ function onVideoReady(_info: VideoInfo, _index: number) {
|
|||||||
// 可在此做额外处理
|
// 可在此做额外处理
|
||||||
}
|
}
|
||||||
|
|
||||||
function connectMqtt() {
|
async function connectMqtt() {
|
||||||
mqttClient = mqtt.connect(`ws://${config.serverIp}:${config.websocket}/mqtt`, {
|
var mqttServerInfo = await apis.GetMqttServerProxyInfo()
|
||||||
username: config.mqttAuth[0],
|
if (!mqttServerInfo.server) return
|
||||||
password: config.mqttAuth[1],
|
mqttClient = mqtt.connect(mqttServerInfo.server, {
|
||||||
|
username:mqttServerInfo.username,
|
||||||
|
password:mqttServerInfo.password,
|
||||||
})
|
})
|
||||||
mqttClient.subscribe(config.resultTopic, { qos: 0 })
|
mqttClient.subscribe(config.resultTopic, { qos: 0 })
|
||||||
mqttClient.subscribe(config.streamInfoTopic, { qos: 0 })
|
mqttClient.subscribe(config.streamInfoTopic, { qos: 0 })
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import type { GlobalConfig, SourceItem } from '../types'
|
import type { GlobalConfig, SourceItem, MqttServerInfo, DeviceItem } from '../types'
|
||||||
// import { generateSignature, generateRandomString } from '../utils/signature'
|
// import { generateSignature, generateRandomString } from '../utils/signature'
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function createApis(config: GlobalConfig) {
|
export function createApis(config: GlobalConfig) {
|
||||||
@ -35,9 +35,13 @@ export function createApis(config: GlobalConfig) {
|
|||||||
return await window.HybridWebView.InvokeDotNet<string>('SubscribeLiveAsync', [deviceId, source_id])
|
return await window.HybridWebView.InvokeDotNet<string>('SubscribeLiveAsync', [deviceId, source_id])
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getMqttServerProxyUrl(): Promise<{ data: string }> {
|
async function GetMqttServerProxyInfo(): Promise<MqttServerInfo> {
|
||||||
return await window.HybridWebView.InvokeDotNet<{ data: string }>('GetMqttServerProxyUrlAsync')
|
return await window.HybridWebView.InvokeDotNet<MqttServerInfo>('GetMqttServerProxyInfo')
|
||||||
}
|
}
|
||||||
|
|
||||||
return { getSources, subscribeLive, getMqttServerProxyUrl }
|
async function getDevices(): Promise<DeviceItem[]> {
|
||||||
|
return await window.HybridWebView.InvokeDotNet<DeviceItem[]>('GetDevicesAsync')
|
||||||
|
}
|
||||||
|
|
||||||
|
return { getSources, subscribeLive, GetMqttServerProxyInfo }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -99,3 +99,14 @@ export interface BboxData {
|
|||||||
export interface DetectionResult {
|
export interface DetectionResult {
|
||||||
bbox: BboxData
|
bbox: BboxData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MqttServerInfo {
|
||||||
|
username: string
|
||||||
|
password: string
|
||||||
|
server: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DeviceItem {
|
||||||
|
DeviceId: string
|
||||||
|
DeviceName: string
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user