Commit 3e88f29b by 周田

mod: 注销组件时,关闭 websocket 通信

parent 3e57e0f6
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted, watch } from 'vue'; import { ref, onMounted, watch, onBeforeUnmount } from 'vue';
import { ElScrollbar, ElInput, ElButton, ElSelect, ElOption, ElMessage } from 'element-plus'; import { ElScrollbar, ElInput, ElButton, ElSelect, ElOption, ElMessage } from 'element-plus';
import DevicePerformanceTable from '@/components/home/DevicePerformanceTabel' import DevicePerformanceTable from '@/components/home/DevicePerformanceTabel'
import axios from 'axios'; import axios from 'axios';
...@@ -113,6 +113,10 @@ onMounted(() => { ...@@ -113,6 +113,10 @@ onMounted(() => {
}) })
}) })
onBeforeUnmount(() => {
chatSocket?.close();
})
// 添加设备监控操作 // 添加设备监控操作
const deviceInfos = ref<any[]>([]); const deviceInfos = ref<any[]>([]);
const selectedDeviceName = ref<string>('') const selectedDeviceName = ref<string>('')
......
...@@ -74,9 +74,7 @@ const del = () => { ...@@ -74,9 +74,7 @@ const del = () => {
} }
onBeforeUnmount(() => { onBeforeUnmount(() => {
if (table_websocket!.OPEN) { table_websocket?.close()
table_websocket!.close()
}
}) })
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment