From 941f9c3db2109f9c05e384299da5f2be309e3939 Mon Sep 17 00:00:00 2001 From: Ivanov N Date: Sun, 15 Dec 2024 22:45:11 +0300 Subject: [PATCH] check url local --- src/store/plugins/navigatorOnline.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/store/plugins/navigatorOnline.js b/src/store/plugins/navigatorOnline.js index 7d334e2b5..800cd2597 100644 --- a/src/store/plugins/navigatorOnline.js +++ b/src/store/plugins/navigatorOnline.js @@ -1,7 +1,7 @@ import { i18n } from '@/i18n' import axios from 'axios' -const checkUrl = 'https://ipv4.icanhazip.com' +const checkUrl = 'robots.txt' export default (store) => { // window.addEventListener('online', handleEvent) @@ -14,18 +14,20 @@ export default (store) => { // store.commit('setIsOnline', false) // } - setInterval(async () => { - const res = Boolean(await inetConnectionCheck()) - const storeVal = store.getters['isOnline'] - if (storeVal !== res) { - store.commit('setIsOnline', res) - const snackMsg = res ? 'online' : 'offline' - store.dispatch('snackbar/show', { - message: i18n.global.t(`connection.${snackMsg}`), - timeout: 3000 - }) - } - }, 1000) + window.onload = () => { + setInterval(async () => { + const res = Boolean(await inetConnectionCheck()) + const storeVal = store.getters['isOnline'] + if (storeVal !== res) { + store.commit('setIsOnline', res) + const snackMsg = res ? 'online' : 'offline' + store.dispatch('snackbar/show', { + message: i18n.global.t(`connection.${snackMsg}`), + timeout: 3000 + }) + } + }, 1000) + } } const inetConnectionCheck = async () => {