|
@@ -2,7 +2,7 @@
|
|
|
import { ref } from "vue";
|
|
|
import titHeader from "./components/tit-header.vue";
|
|
|
import ConfigDataAndDevice from "./components/configDataAndDevice.vue";
|
|
|
-
|
|
|
+import { useWebSocket } from "@vueuse/core";
|
|
|
import { useCommonStoreHook } from "@/store";
|
|
|
import { getTestProjectList } from "@/api/project";
|
|
|
import { CheckboxValueType } from "element-plus";
|
|
@@ -158,6 +158,33 @@ const getSattisticData = () => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
+// ===== websocket ====
|
|
|
+const wsClient = useWebSocket(import.meta.env.VITE_WEBSOCKET_URL as string, {
|
|
|
+ autoReconnect: {
|
|
|
+ retries: 300,
|
|
|
+ delay: 3000,
|
|
|
+ onFailed() {
|
|
|
+ console.log("长链接失败");
|
|
|
+ },
|
|
|
+ },
|
|
|
+ heartbeat: {
|
|
|
+ message: "ping",
|
|
|
+ interval: 1000,
|
|
|
+ pongTimeout: 1000,
|
|
|
+ },
|
|
|
+ onMessage: (msg) => {
|
|
|
+ console.log("长链接的消息", msg);
|
|
|
+ },
|
|
|
+});
|
|
|
+
|
|
|
+// onMounted(() => {
|
|
|
+//
|
|
|
+// });
|
|
|
+
|
|
|
+onBeforeUnmount(() => {
|
|
|
+ wsClient.close();
|
|
|
+});
|
|
|
+
|
|
|
const checkStartEnable = (): boolean => {
|
|
|
let enable = true;
|
|
|
|