|
|
|
|
@ -10,6 +10,7 @@
|
|
|
|
|
import ThemePicker from "@/components/ThemePicker";
|
|
|
|
|
import AlmModal from "@/components/AlmModal";
|
|
|
|
|
|
|
|
|
|
let timeInterval = null;
|
|
|
|
|
export default {
|
|
|
|
|
name: "App",
|
|
|
|
|
components: {ThemePicker, AlmModal},
|
|
|
|
|
@ -47,6 +48,9 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
timeInterval = setInterval(() => {
|
|
|
|
|
this.selectOffLineDevice()
|
|
|
|
|
})
|
|
|
|
|
console.log('App mounted - 初始化全局WebSocket连接')
|
|
|
|
|
this.initGlobalWebSocket()
|
|
|
|
|
|
|
|
|
|
@ -58,6 +62,8 @@ export default {
|
|
|
|
|
beforeDestroy() {
|
|
|
|
|
console.log('App beforeDestroy - 清理WebSocket连接')
|
|
|
|
|
this.cleanup()
|
|
|
|
|
timeInterval && clearInterval(timeInterval)
|
|
|
|
|
timeInterval = null
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
// 初始化全局WebSocket连接
|
|
|
|
|
@ -362,6 +368,7 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
selectOffLineDevice() {
|
|
|
|
|
Object.keys(this.isOnline).forEach(key => {
|
|
|
|
|
// console.log(key, new Date().getTime() - this.isOnline[key])
|
|
|
|
|
if (new Date().getTime() - this.isOnline[key] > (1000 * 60 * 30)) {
|
|
|
|
|
this.$confirm(`设备${key}已离线`, '设备离线', {
|
|
|
|
|
cancelButtonText: '关闭',
|
|
|
|
|
|