李富豪 1 жил өмнө
parent
commit
89c0bd71f4

+ 3 - 5
Web/src/components/g-map/DroneControlPanel.vue

@@ -313,7 +313,7 @@ const props = defineProps<{
 const store = useMyStore()
 
 const clientId = computed(() => {
-  return store.state.clientId
+  return store.state.clientId;
 })
 
 const initCmdList = baseCmdList.map(cmdItem => Object.assign({}, cmdItem))
@@ -488,9 +488,8 @@ async function onClickFightControl() {
 // 进入飞行控制
 async function enterFlightControl() {
   try {
-    const clientId = localStorage.getItem('client_id') || '';
     const { code, data } = await postDrcEnter({
-      client_id: clientId,
+      client_id: clientId.value,
       dock_sn: props.sn,
     })
     if (code === 0) {
@@ -514,9 +513,8 @@ async function enterFlightControl() {
 // 退出飞行控制
 async function exitFlightCOntrol() {
   try {
-    const clientId = localStorage.getItem('client_id') || '';
     const { code } = await postDrcExit({
-      client_id: clientId,
+      client_id: clientId.value,
       dock_sn: props.sn,
     })
     if (code === 0) {

+ 2 - 6
Web/src/components/g-map/use-connect-mqtt.ts

@@ -28,9 +28,8 @@ export function useConnectMqtt() {
     if (val) {
       if (mqttState.value) return
       const result = await postDrc({})
-      localStorage.removeItem('client_id');
       if (result?.code === 0) {
-        const { address, client_id, username, password, expire_time } = result.data
+        const { address, client_id, username, password, expire_time } = result.data;
         // @TODO: 校验 expire_time
         mqttState.value = new UranusMqtt(address, {
           clientId: client_id,
@@ -41,10 +40,8 @@ export function useConnectMqtt() {
         mqttState.value?.on('onStatus', (statusOptions: StatusOptions) => {
           // @TODO: 异常case
         })
-
         store.commit('SET_MQTT_STATE', mqttState.value)
-        store.commit('SET_CLIENT_ID', client_id)
-        localStorage.setItem('client_id', client_id)
+        store.commit('SET_CLIENT_ID', client_id);
       }
       // @TODO: 认证失败case
       return
@@ -56,7 +53,6 @@ export function useConnectMqtt() {
       mqttState.value = null
       store.commit('SET_MQTT_STATE', null)
       store.commit('SET_CLIENT_ID', '')
-      localStorage.removeItem('client_id')
     }
   }, { immediate: true })