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(); });