<template>
  <div id="home">
    <contentData id="contentData" :signaData="signaData" :homeData="homeData" />
    <map-control id="mapControl" :signaData="signaData" :homeData="homeData" />
  </div>
</template>

<script>
"use script";
import mapControl from "./mapControl/index.vue";
import contentData from "./contentData/index.vue";
import { Homeview } from "@/api/home.js";
// import * as signalR from "@microsoft/signalr";
export default {
  name: "HomeIndex",
  data() {
    return {
      signaData: {},
      homeData: {},
      timeInterval: null
    };
  },
  components: {
    mapControl,
    contentData
    // whiteListForm
  },
  created() {},
  // watch: {
  //   signaData: {
  //     handler(val) {
  //       if (val) {
  //         if (val.messageType === "alarm") {
  //           // this.timeInterval = setTimeout(() => {
  //           //   clearTimeout(this.timeInterval);
  //           // }, 3000);
  //         }
  //       }
  //     },
  //     immediate: true
  //   }
  // },
  mounted() {
    this.initHomeData();
    this.timeInterval = setInterval(() => {
      this.initHomeData();
    }, 1000);
  },
  methods: {
    initHomeData() {
      Homeview().then((res) => {
        if (res.code === 0) {
          this.homeData = res.data;
        }
      });
    }
  },
  // 页面销毁
  beforeDestroy() {
    clearInterval(this.timeInterval);
  }
};
</script>
<style scoped lang="scss"></style>
