From fc78bb0865568a7b1d247d82a63963440cd7969d Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Sat, 22 Jun 2024 10:37:32 +0800 Subject: [PATCH] feat: reconnect if web socket is closed --- frontend/src/pages/monitor/[hostname].vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/frontend/src/pages/monitor/[hostname].vue b/frontend/src/pages/monitor/[hostname].vue index 7128147..7e8311a 100644 --- a/frontend/src/pages/monitor/[hostname].vue +++ b/frontend/src/pages/monitor/[hostname].vue @@ -34,6 +34,12 @@ export default { window.scrollTo(0, document.body.scrollHeight); }, 100); }; + this.socket.onclose = (event) => { + // reconnect after 1s + setTimeout(() => { + this.fetchData(); + }, 1000); + } }, }, };