From b7c3a51759c608344a4e0cb592c5739f3d495926 Mon Sep 17 00:00:00 2001 From: liaoxinyu Date: Fri, 20 Sep 2024 18:24:48 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E5=90=8E=E4=BB=8E=E6=96=B0?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=B0=B1=E8=AF=B7=E6=B1=82=E4=B8=80=E6=AC=A1?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/App.vue b/App.vue index e865a4e..716b4bf 100644 --- a/App.vue +++ b/App.vue @@ -29,9 +29,9 @@ export default { }, sendHeartbeat() { - Home.online().then((response) => { - console.log('心跳机制'); - }).catch((err) => {}); + Home.online().then((response) => { + console.log('心跳机制'); + }).catch((err) => {}); }, startHeartbeat() { if (!this.heartbeatInterval && this.isLogin) { @@ -171,6 +171,10 @@ export default { mounted() { // 监听页面可见性变化 document.addEventListener('visibilitychange', this.handleVisibilityChange); + // 立即发送一次心跳请求 + if (this.isLogin){ + this.sendHeartbeat() + } // 启动心跳机制 this.startHeartbeat(); },