wuyouming666
2024-08-02 7641b0424d6222eed67c50092521e1858666f9ad
UI-Project/src/views/Caching/cachingun.vue
@@ -60,7 +60,7 @@
const adda = ref(false)
import { WebSocketHost ,host} from '@/utils/constants'
import request from "@/utils/request"
import { ref, onMounted , onBeforeUnmount} from "vue";
import { ref, onMounted , onUnmounted} from "vue";
import { initializeWebSocket, closeWebSocket } from '@/utils/WebSocketService';
// import { ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
@@ -204,7 +204,7 @@
};
let socket =null;
const socketUrl = `ws://${WebSocketHost}:${host}/api/unLoadGlass/api/talk/downcache`;
// 定义消息处理函数,更新 receivedData 变量
const handleMessage = (data) => {
@@ -223,12 +223,12 @@
onMounted(() => {
  // fetchFlowCardId();
  // fetchTableData(); // 获取数据
  initializeWebSocket(socketUrl, handleMessage);
  socket =  initializeWebSocket(socketUrl, handleMessage);
});
onBeforeUnmount(() => {
onUnmounted(() => {
  console.log("关闭了")
  closeWebSocket();
  closeWebSocket(socket);
});
</script>
<style scoped>