获取设备列表
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() {
|
||||
mqttClient = mqtt.connect(`ws://${config.serverIp}:${config.websocket}/mqtt`, {
|
||||
username: config.mqttAuth[0],
|
||||
password: config.mqttAuth[1],
|
||||
async function connectMqtt() {
|
||||
var mqttServerInfo = await apis.GetMqttServerProxyInfo()
|
||||
if (!mqttServerInfo.server) return
|
||||
mqttClient = mqtt.connect(mqttServerInfo.server, {
|
||||
username:mqttServerInfo.username,
|
||||
password:mqttServerInfo.password,
|
||||
})
|
||||
mqttClient.subscribe(config.resultTopic, { 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'
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
export function createApis(config: GlobalConfig) {
|
||||
@ -35,9 +35,13 @@ export function createApis(config: GlobalConfig) {
|
||||
return await window.HybridWebView.InvokeDotNet<string>('SubscribeLiveAsync', [deviceId, source_id])
|
||||
}
|
||||
|
||||
async function getMqttServerProxyUrl(): Promise<{ data: string }> {
|
||||
return await window.HybridWebView.InvokeDotNet<{ data: string }>('GetMqttServerProxyUrlAsync')
|
||||
async function GetMqttServerProxyInfo(): Promise<MqttServerInfo> {
|
||||
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 {
|
||||
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