|
@@ -9,18 +9,33 @@
|
|
|
|
|
|
export default {
|
|
|
methods: {
|
|
|
- startNetWatcher() {
|
|
|
- this.intevalId = setInterval(() => {
|
|
|
- const url = '/web/static/src/img/favicon.ico?_=' + new Date().getTime()
|
|
|
- axios.get(url).then(() => {
|
|
|
+ startPolling() {
|
|
|
+ this.polling = true
|
|
|
+
|
|
|
+ const poll = () => {
|
|
|
+ if (!this.polling) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const frame = Math.round(Math.random() * 5000)
|
|
|
+
|
|
|
+ axios.request({
|
|
|
+ url: '/web/static/src/img/favicon.ico?_=' + new Date().getTime(),
|
|
|
+ method: 'get',
|
|
|
+ timeout: 2000
|
|
|
+ }).then(() => {
|
|
|
this.isWired = true
|
|
|
+ setTimeout(poll, frame)
|
|
|
}).catch(() => {
|
|
|
this.isWired = false
|
|
|
+ setTimeout(poll, frame)
|
|
|
})
|
|
|
- }, 1000)
|
|
|
+ }
|
|
|
+
|
|
|
+ poll()
|
|
|
},
|
|
|
- stopNetWatcher() {
|
|
|
- clearInterval(this.intevalId)
|
|
|
+ stopPolling() {
|
|
|
+ this.polling = false
|
|
|
},
|
|
|
notifyNetStatus() {
|
|
|
this.$emit('onChangeNet', this.isWired)
|
|
@@ -41,14 +56,15 @@
|
|
|
return {
|
|
|
message: 'Estableciendo conexión',
|
|
|
isWired: false,
|
|
|
- intevalId: null
|
|
|
+ polling: true
|
|
|
+ // intevalId: null
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.startNetWatcher()
|
|
|
+ this.startPolling()
|
|
|
},
|
|
|
destroyed() {
|
|
|
- this.stopNetWatcher()
|
|
|
+ this.stopPolling()
|
|
|
}
|
|
|
}
|
|
|
</script>
|