<template>
  <div class="subject">
    <div class="subject_header">
      <div class="subject_header_title">
        <span>临沂市自然资源无人机全域巡查平台</span>
      </div>
      <div class="logout" title="退出登录">
        <Icon
          style="font-size: 30px; color: #fff; cursor: pointer"
          icon="ion:power-outline"
          @click="handleLoginOut()"
        />
      </div>
    </div>
    <div class="subject_title">
      <div>
        <span>欢迎登陆，临沂市自然资源无人机全域巡查平台</span>
      </div>
    </div>
    <div class="subject_btnBox">
      <div v-for="(item, index) in list" :key="item.id" class="subject_btnBox_div">
        <a @click="getHome(item.id)">
          <img :src="getImageUrl(item.imgUrl)" />
          <pre :style="{ left: `${280 * index}px` }">{{ item.title.replace(/\s/g, '\n') }}</pre>
        </a>
      </div>
      <div class="subject_btnBox_div">
        <a @click="getHome('')">
          <img :src="getImageUrl('')" />
          <pre :style="{ left: `${280 * list.length}px` }">后台管理</pre>
        </a>
      </div>
    </div>
    <div class="subject_bottom">
      <span>
        版权所有：临沂市自然资源和规划局&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp;
        技术⽀持：山东慧创信息科技有限公司&nbsp;&nbsp;&nbsp; |&nbsp;&nbsp;&nbsp; 系统版本： 20241230
      </span>
    </div>
  </div>
</template>
<script setup lang="ts">
  import { useUserStore } from '@/store/modules/user';
  // import { getSpecialData } from '@/api/demo/system';
  import { LoadDataBaseInfo } from '@/api/sys/specialcolumn';
  import { onMounted, ref } from 'vue';
  import Icon from '@/components/Icon/Icon.vue';

  const list: any = ref([]);
  const userStore = useUserStore();
  async function getData() {
    const res: any = await LoadDataBaseInfo();
    list.value = [];
    if (res.items) {
      list.value = res.items.filter((item) => item.isShow == true);
    }
  }
  onMounted(() => {
    getData();
  });
  async function getHome(name) {
    console.log(name);
    userStore.setSubject(name);
  }
  function getImageUrl(imgUrl) {
    if (imgUrl) {
      return 'http://192.168.10.102:9023' + '/' + imgUrl;
    } else {
      return '/subject_default.png';
    }
  }
  // 退出系统
  function handleLoginOut() {
    userStore.confirmLoginOut();
  }
</script>
<style lang="less" scoped>
  .subject {
    background-image: url('/subject_bg.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    background-attachment: fixed;
    width: 100%;
    height: 100%;

    &_header {
      background-image: url('/subject_header.png');
      background-repeat: no-repeat;
      background-size: cover;
      height: 82px;
      width: 100%;

      &_title {
        position: absolute;
        top: 19px;
        left: 35%;
        transform: translateX(0%);

        span {
          width: 592px;
          height: 43px;
          font-family: 068-SSZhengYaTi;
          font-weight: 400;
          font-size: 40px;
          color: #ffffff;
        }
      }
    }

    &_title {
      background-image: url('/subject_title.png');
      position: absolute;
      top: 112px;
      left: 35%;
      height: 133px;
      width: 800px;

      span {
        position: absolute;
        top: 49px;
        left: -35px;
        width: 800px;
        height: 37px;
        font-family: PingFang SC;
        font-weight: 400;
        font-size: 36px;
        color: #ffffff;
        line-height: 28px;
      }
    }

    &_btnBox {
      position: absolute;
      top: 340px;
      left: 118px;
      display: flex;

      &_div {
        margin-right: 30px;
        width: 250px;

        a img {
          height: 362px;
        }

        a pre {
          display: inline-flex;
          align-items: center;
          justify-content: center;
          position: absolute;
          top: 240px;
          width: 250px;
          // 字体样式
          font-size: 24px;

          font-family: 068-SSZhengYaTi;
          color: #ffffff;
          text-shadow: 0px 2px 10px rgba(10, 30, 52, 0.48);
          background: linear-gradient(0deg, #6da7ff 0%, #e2ebff 100%);
          -webkit-background-clip: text;
          -webkit-text-fill-color: transparent;
          background-clip: text;
          color: transparent;
          font-weight: bold !important;
        }
      }
    }

    &_bottom {
      span {
        width: 902px;
        height: 18px;
        font-family: PingFang SC;
        font-weight: 400;
        font-size: 18px;
        color: #5eb2ff;
      }
      position: absolute;
      top: 95%;
      left: 30%;
    }
  }
  .logout {
    position: absolute;
    right: 100px;
    top: 30px;
  }
</style>
