This commit is contained in:
gyq
2024-07-12 17:12:51 +08:00
parent 8c1e1d3fbc
commit 815b6e0a25
6 changed files with 22 additions and 221 deletions

View File

@@ -164,8 +164,12 @@ async function getBarCode(e) {
}
// 获取网络状态
const updateInfo = _.throttle(function (isOnLine) {
const updateInfo = _.throttle(function () {
let isOnLine = navigator.onLine
// // 获取网络信息
// let info = navigator.connection
console.log(isOnLine);
// console.log(info);
if (store.userInfo && store.userInfo.shopId) {
if (isOnLine) {
console.log('有网了重新连接ws~');
@@ -187,10 +191,12 @@ onMounted(() => {
socket.init();
}
// 监听网络在线状态
window.addEventListener("onLine", updateInfo(true))
// 监听网络离线
window.addEventListener("offLine", updateInfo(false))
// // 监听网络在线状态
// window.addEventListener("onLine", updateInfo)
// // 监听网络离线
// window.addEventListener("offLine", updateInfo)
// 监听网络信息变化
// navigator.connection.addEventListener('change', updateInfo)
});
</script>