ZaiZai 6 months ago
parent
commit
80b70f4567
3 changed files with 9 additions and 4 deletions
  1. 1 1
      public/version.json
  2. 1 1
      src/config/index.json
  3. 7 2
      src/layout/index.vue

+ 1 - 1
public/version.json

@@ -1,3 +1,3 @@
 {
-  "value": "20240820100702"
+  "value": "20240821143956"
 }

+ 1 - 1
src/config/index.json

@@ -3,7 +3,7 @@
     "target1": "http://192.168.0.109:8090",
     "target": "http://39.108.216.210:8090",
     "target3": "http://183.247.216.148:28090",
-    "socket1": "wss://measure.hczcxx.cn/websocket",
+    "socket": "wss://measure.hczcxx.cn/websocket",
     "smsPhone": "",
     "vite": {
         "port": 5175,

+ 7 - 2
src/layout/index.vue

@@ -52,7 +52,7 @@
 </template>
 
 <script setup>
-import { nextTick, onMounted, ref, watch } from 'vue'
+import { nextTick, onMounted, onUnmounted, ref, watch } from 'vue'
 import { useAppStore } from '~src/store'
 import { useRoute, useRouter } from 'vue-router'
 import { initButtons } from '~sto/app'
@@ -166,7 +166,7 @@ const cascaderSend = async ({ projectId, contractId }) => {
     await useClick()
     //链接webSocket
     if (!isNullES(socket)) socket.close()
-    socket = new HcSocket({ projectId, contractId, userId: userId.value }, (data) => {
+    socket = new HcSocket({ projectId, contractId, userId: userId.value }, ({ data }) => {
         console.log('socket:', data)
     })
 }
@@ -187,6 +187,11 @@ const logoClick = () => {
 const userProjectClick = () => {
     router.push({ path: '/user/project' })
 }
+
+//页面卸载
+onUnmounted(() => {
+    if (!isNullES(socket)) socket.close()
+})
 </script>
 
 <style lang="scss">