|
|
|
@ -5,6 +5,7 @@ import BottomBar from "@/components/BottomBar.vue";
|
|
|
|
|
import Toolbar from "@/components/toolbar.vue";
|
|
|
|
|
import CollisionDetection from "@/components/CollisionDetection.vue";
|
|
|
|
|
import {useMessage} from 'naive-ui'
|
|
|
|
|
import {useStaticStore} from "@/store/staticOptions.js";
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
name: "HomePage",
|
|
|
|
@ -13,8 +14,32 @@ export default defineComponent({
|
|
|
|
|
return {
|
|
|
|
|
showDetection: false,
|
|
|
|
|
graphHeight: 0,
|
|
|
|
|
message: useMessage()
|
|
|
|
|
message: useMessage(),
|
|
|
|
|
staticStore: useStaticStore(),
|
|
|
|
|
timeId: undefined,
|
|
|
|
|
msgbox: true,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
if(!window.navigator.onLine) {
|
|
|
|
|
this.message.warning('无法连接互联网,当前为离线模式')
|
|
|
|
|
this.staticStore.networkStatus.offlineMode = true
|
|
|
|
|
}else{
|
|
|
|
|
this.setNetworkTimer()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 网络状态监测
|
|
|
|
|
window.addEventListener('online', () => {
|
|
|
|
|
this.message.success('网络已连接')
|
|
|
|
|
this.staticStore.networkStatus.offlineMode = false
|
|
|
|
|
this.setNetworkTimer()
|
|
|
|
|
})
|
|
|
|
|
window.addEventListener('offline', () => {
|
|
|
|
|
this.message.warning('无法连接互联网,已进入离线模式')
|
|
|
|
|
this.staticStore.networkStatus.offlineMode = true
|
|
|
|
|
// 关闭网络检测定时器
|
|
|
|
|
this.timeId && clearInterval(this.timeId)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
setPageStyle: function () {
|
|
|
|
@ -31,6 +56,24 @@ export default defineComponent({
|
|
|
|
|
this.showDetection = true
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
setNetworkTimer(){
|
|
|
|
|
this.timeId = setInterval(()=>{
|
|
|
|
|
console.log(navigator['connection'].downlink)
|
|
|
|
|
if(navigator['connection'].downlink < 1){
|
|
|
|
|
this.staticStore.networkStatus.offlineMode = true
|
|
|
|
|
if(this.msgbox){
|
|
|
|
|
this.message.warning('检测到当前网络环境差,已切换至离线模式')
|
|
|
|
|
this.msgbox = false
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
this.staticStore.networkStatus.offlineMode = false
|
|
|
|
|
if(!this.msgbox){
|
|
|
|
|
this.msgbox = true
|
|
|
|
|
this.message.info('已切换至在线模式')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},3000)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
</script>
|
|
|
|
|