diff --git a/src/assets/images/flightoperation/sdr.png b/src/assets/images/flightoperation/sdr.png new file mode 100644 index 0000000..7716ce8 Binary files /dev/null and b/src/assets/images/flightoperation/sdr.png differ diff --git a/src/utils/debugging/events.ts b/src/utils/debugging/events.ts new file mode 100644 index 0000000..696285d --- /dev/null +++ b/src/utils/debugging/events.ts @@ -0,0 +1,23 @@ +import { clientReizePublish, clientReizeSubscribe } from '@/utils/mqtt'; + +export const eventsTopic = (data) => { + // 发送消息 + clientReizePublish('thing/product/8UUXN5400A079H/events', data); +}; +export const events_replyTopic = () => { + // 订阅消息 + clientReizeSubscribe('thing/product/8UUXN5400A079H/events_reply'); +}; + +export const servicesTopic = (data) => { + // 发送消息 + clientReizePublish('thing/product/8UUXN5400A079H/services', data); +}; +export const services_replyTopic = () => { + // 订阅消息 + clientReizeSubscribe('thing/product/8UUXN5400A079H/services_reply'); +}; +export const drcDownTopic = (data) => { + // 发送消息thing/product/{gateway_sn}/drc/down + clientReizePublish('thing/product/8UUXN5400A079H/drc/down', data); +}; diff --git a/src/utils/mqtt.ts b/src/utils/mqtt.ts index f8dd967..5b704a7 100644 --- a/src/utils/mqtt.ts +++ b/src/utils/mqtt.ts @@ -18,6 +18,7 @@ const connection = { username: 'sdhc', password: '', }; + let client: any = { connected: false, }; @@ -105,6 +106,51 @@ const clientPublish = (topic: string, querys: any) => { // subscribe 事件 订阅 // unsubscribe 事件 取消订阅 +// 抢夺负载权、飞行控制权的时候使用 +const client_seize: any = { + connected: false, +}; +const createSeizeConnection = () => { + const seizeConnection = connection; + seizeConnection.clientId = 'mqtt_client_1581F8HGX254V00A0BUY_seize'; + try { + const { protocol, host, port, endpoint, ...options } = seizeConnection; + const connectUrl = `${protocol}://${host}:${port}${endpoint}`; + client_seize = mqtt.connect(connectUrl, options); + if (client.on) { + } + } catch (error) { + console.log('mqtt.connect error', error); + } +}; +const getReizeClient = () => { + if (!client_seize || !client_seize.connected) { + getReizeClient(); + } + return client_seize; +}; +// 订阅事件 +const clientReizeSubscribe = (topic: string, options?: any) => { + console.log(client_seize); + if (!client_seize || !client_seize.connected) { + createConnection(); + } + getReizeClient().subscribe(topic, { qos: 0 }, (error, res) => { + console.log('订阅'); + console.log(error, res); + }); +}; +// 发送消息 +const clientReizePublish = (topic: string, querys: any) => { + if (!client_seize || !client_seize.connected) { + createConnection(); + } + getReizeClient().publish(topic, JSON.stringify(querys), { qos: 0 }, (err) => { + if (err) { + console.error('Publish error:', err); + } + }); +}; export { // 连接 createConnection, @@ -112,4 +158,8 @@ export { getClient, clientSubscribe, clientPublish, + createSeizeConnection, + getReizeClient, + clientReizeSubscribe, + clientReizePublish, }; diff --git a/src/views/demo/system/mediaLibrary/LeftTree.vue b/src/views/demo/system/mediaLibrary/LeftTree.vue index 27ada46..ae51731 100644 --- a/src/views/demo/system/mediaLibrary/LeftTree.vue +++ b/src/views/demo/system/mediaLibrary/LeftTree.vue @@ -18,12 +18,10 @@ const emit = defineEmits(['select']); - const treeData = ref([]); + const treeData: any = ref([]); const asyncExpandTreeRef = ref>(null); async function fetch() { - // treeData.value = (await getChildrenTree({ parentId: 0 })) as unknown as TreeItem[]; - // console.log(treeData.value); treeData.value = [ { id: 'meitiku', @@ -65,14 +63,14 @@ }, ], }, - { - id: 'gas', - name: '气体探测', - }, - { - id: 'vr', - name: 'VR全景', - }, + // { + // id: 'gas', + // name: '气体探测', + // }, + // { + // id: 'vr', + // name: 'VR全景', + // }, ]; // 显示到一级 diff --git a/src/views/demo/system/mediaLibrary/index.vue b/src/views/demo/system/mediaLibrary/index.vue index 080ab6b..b1990ca 100644 --- a/src/views/demo/system/mediaLibrary/index.vue +++ b/src/views/demo/system/mediaLibrary/index.vue @@ -1,42 +1,186 @@