Commit be3844a9 authored by “yiyousong”'s avatar “yiyousong”

feat:添加断网提示

parent bc2d39d8
<template> <template>
<div class="app"> <div class="app">
<router-view></router-view> <router-view></router-view>
<NetworkError :isShowError="isShowError"></NetworkError>
</div> </div>
</template> </template>
<script> <script>
import local from "@/utils/local"; import local from "@/utils/local";
import NetworkError from "@/components/NetworkError.vue";
import mq from "@/mixin/mq"; import mq from "@/mixin/mq";
import { getHomeInfo } from "@/api"; import { getHomeInfo } from "@/api";
import { mapMutations } from "vuex"; import { mapMutations } from "vuex";
export default { export default {
mixins: [mq], mixins: [mq],
components: {
NetworkError,
},
data() { data() {
return { return {
routeQuery: "", routeQuery: "",
devicenum: "", devicenum: "",
linkDom: null, // 换皮 linkDom: null, // 换皮
isShowError: false,
}; };
}, },
watch: { watch: {
...@@ -58,6 +64,17 @@ export default { ...@@ -58,6 +64,17 @@ export default {
this.WebSocketMq(obj); this.WebSocketMq(obj);
} }
}, },
mounted() {
// 设备在线
window.addEventListener("online", () => {
this.isShowError = false;
location.reload();
});
// 设备离线
window.addEventListener("offline", () => {
this.isShowError = true;
});
},
methods: { methods: {
...mapMutations(["SET_homeInfo", "SET_datumList", "SET_matterList"]), ...mapMutations(["SET_homeInfo", "SET_datumList", "SET_matterList"]),
// 简析url // 简析url
......
<template>
<div class="network_error" v-show="isShowError">
<div class="network_error_box">
<img class="network_error_img" src="../assets/img/网络出错@3x.png" />
</div>
</div>
</template>
<script>
export default {
props: {
isShowError: {
type: Boolean,
required: true,
default: false,
},
},
};
</script>
<style lang="less" scoped>
.network_error {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.2);
position: fixed;
top: 0px;
left: 0px;
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
.network_error_box {
width: 400px;
height: 400px;
background-color: #fff;
border-radius: 4px;
.network_error_img {
width: 100%;
height: 100%;
}
}
}
</style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment