<template>
  <div class="common-box" style="margin-top: 20px">
    <TopTitle icon="daping" title="大屏入口" />
    <div class="sys-container">
      <div
        v-for="(item, index) in screenData"
        :key="index"
        class="sys-item"
        @click="gotoScreen(item.routeName)"
      >
        <img :src="item.src" class="sys-item-img" />
        <h3 class="sys-item-title">{{ item.name }}</h3>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import TopTitle from "@/components/TopTitle.vue";
import { useFullscreen } from "@vueuse/core";

const el = ref<HTMLElement>();
const { isFullscreen, toggle, enter, exit } = useFullscreen(el);
const screenData = ref([
  {
    name: "综合监控大屏",
    routeName: "mainScreen",
    src: new URL("@/assets/images/mainScreen.png", import.meta.url),
  },
  {
    name: "质量综合大屏",
    routeName: "qualityScreen",
    src: new URL("@/assets/images/qualityScreen.png", import.meta.url),
  },
  {
    name: "总装车间看板",
    routeName: "workScreen",
    src: new URL("@/assets/images/workScreen.png", import.meta.url),
  },
  {
    name: "设备监控看板",
    routeName: "deviceScreen",
    src: new URL("@/assets/images/deviceScreen.png", import.meta.url),
  },
  {
    name: "测试大屏",
    routeName: "totalScreen",
    src: new URL("@/assets/images/deviceScreen.png", import.meta.url),
  },
]);

const router = useRouter();
const gotoScreen = (routeName: string) => {
  router.push({ name: routeName });
  if (!isFullscreen.value) {
    enter();
  }
  // document.body.style.transform = "scale(1)";
  // document.body.style.transformOrigin = "top left";
  // document.body.style.zoom = "100%";
};
</script>

<style lang="scss" scoped>
.sys-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}

.sys-item {
  min-width: 150px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;

  .sys-item-img {
    width: 160px;
    height: 90px;
    border-radius: 5px;
  }

  .sys-item-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
  }
}

.sys-item:hover {
  background-color: #87cefa;
  cursor: pointer;
}
</style>
