<template>
  <div class="scale-wrap" id="fullDiv">
    <div class="bg">
      <div class="host-body">
        <!-- 头部 s -->
        <button @click="toggleFullScreen" style="margin-left: 10px;">{{ fullScreen ? "退出大屏" : "进入大屏" }}</button>
        <div class="d-flex jc-center title_wrap">
          <div class="zuojuxing"></div>
          <div class="youjuxing"></div>
          <div class="guang"></div>
          <div class="d-flex jc-center">
            <div class="title">
              <span class="title-text">5G物联数字农业生产驾驶舱</span>
            </div>
          </div>
          <div class="timers" style="margin-left: 1500px;">
            {{ dateYear }} {{ dateWeek }} {{ dateDay }}
            <i class="blq-icon-shezhi02" style="margin-left: 10px" @click="showSetting"></i>
          </div>
        </div>
        <!-- 头部 e-->
        <!-- 内容  s-->
        <!-- <router-view></router-view> -->
        <index />
        <!-- 内容 e -->
      </div>
    </div>
  </div>
</template>

<script>
import Index from "@/views/index";
import index from '@/views/indexs/index.vue'
import screenFull from 'screenfull';
import { TimeFmt } from "../utils/index.js";
import ScaleScreen from "./components/scale-screen/scale-screen.vue";
export default {
  components: { ScaleScreen, screenFull, index, Index },
  data() {
    return {
      timing: null,
      loading: true,
      dateDay: null,
      dateYear: null,
      dateWeek: null,
      weekday: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
      fullScreen: false, // 用于记录当前是否处于全屏状态，默认为 false
    };
  },
  filters: {
    numsFilter(msg) {
      return msg || 0;
    },
  },
  computed: {},
  created() { },
  mounted() {
    this.timeFn();
    this.cancelLoading();
  },
  beforeDestroy() {
    clearInterval(this.timing);
  },
  methods: {
    showSetting() {
      this.$refs.setting.init();
    },
    timeFn() {
      this.timing = setInterval(() => {
        this.dateDay = TimeFmt(new Date(), "HH: mm: ss");
        this.dateYear = TimeFmt(new Date(), "yyyy-MM-dd");
        this.dateWeek = this.weekday[new Date().getDay()];
      }, 1000);
    },
    cancelLoading() {
      let timer = setTimeout(() => {
        this.loading = false;
        clearTimeout(timer);
      }, 500);
    },
    // 切换全屏状态的方法
    toggleFullScreen() {
      const fullDiv = document.getElementById("fullDiv");
      if (!this.fullScreen && screenFull.isEnabled) {
        // 如果不是全屏状态，并且全屏可用，则进入全屏
        screenFull.request(fullDiv);
        this.fullScreen = true; // 设置全屏状态为 true
      } else if (this.fullScreen && screenFull.isEnabled) {
        // 如果已经是全屏状态，并且全屏可用，则退出全屏
        screenFull.exit();
        this.fullScreen = false; // 设置全屏状态为 false
      }
    },
  },
};
</script>

<style lang="scss">
@import "./home.scss";

/* 设置外层div的宽高 */
.index_home {
  width: 1750px;
  height: 1080px;
  /* 可根据需要添加其他样式，比如居中显示等 */
}

.timers {
  /* 其他样式 */
  margin-left: -100px;
}
</style>
