From d77c4e43d4cc3ba5305f0391ab62d35475fa3856 Mon Sep 17 00:00:00 2001 From: TsMask <340112800@qq.com> Date: Tue, 15 Oct 2024 15:14:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=A1=E4=BB=A4=E8=B7=9F=E8=B8=AA?= =?UTF-8?q?=E4=BF=9D=E6=B4=BB=E7=BB=AD=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/traceManage/wireshark/index.vue | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/views/traceManage/wireshark/index.vue b/src/views/traceManage/wireshark/index.vue index cada1bef..4bd0e6fb 100644 --- a/src/views/traceManage/wireshark/index.vue +++ b/src/views/traceManage/wireshark/index.vue @@ -18,6 +18,7 @@ import { packetStart, packetStop, packetFilter, + packetKeep, } from '@/api/trace/packet'; const ws = new WS(); const { t } = useI18n(); @@ -29,6 +30,8 @@ type StateType = { devices: { id: string; label: string; children: any[] }[]; /**初始化 */ initialized: boolean; + /**保活调度器 */ + keepTimer: any; /**任务 */ task: { taskNo: string; @@ -64,6 +67,7 @@ type StateType = { const state = reactive({ devices: [], initialized: false, + keepTimer: null, task: { taskNo: 'laYlTbq', device: '192.168.5.58', @@ -274,6 +278,9 @@ function wsMessage(res: Record) { // 建联时发送请求 if (!requestId && data.clientId) { state.initialized = true; + state.keepTimer = setInterval(() => { + packetKeep(state.task.taskNo, 120); + }, 90 * 1000); return; } @@ -320,7 +327,9 @@ onMounted(() => { }); onBeforeUnmount(() => { - ws.close(); + clearInterval(state.keepTimer); + state.keepTimer = null; + if (ws.state() === WebSocket.OPEN) ws.close(); });