浏览器提供了navigator.onLine的属性来检测当前网络状态
详细参考: https://justforuse.github.io/blog/zh-cn/2020/01/check-network-status/