<template>
  <div class="common-box">
    <TopTitle icon="xitong" title="系统入口" />
    <div class="sys-container">
      <div
        v-for="(item, index) in sysData"
        :key="index"
        class="sys-item"
        @click="openInNewTab(item.path)"
      >
        <svg-icon
          :icon-class="item.icon"
          alt=""
          class="sys-item-img"
          size="60"
        />
        <h3 class="sys-item-title">{{ item.menuName }}</h3>
        <!--        <div class="unclickable"></div>-->
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useUserStore } from "@/store";
import TopTitle from "@/components/TopTitle.vue";

const userStore = useUserStore();

const sysData = ref<any[]>([]);

onMounted(async () => {
  await userStore.getUserInfo();
  sysData.value = userStore.user.sysData;
});

const openInNewTab = (url: string) => {
  if (url === "email") {
    window.open("email://open");
  } else {
    window.open(url, "_blank");
  }
};
</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;
  position: relative;

  .sys-item-img {
    width: 60px;
  }

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

  .unclickable {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(128, 128, 128, 0.5); /* 灰色蒙层 */
    pointer-events: none; /* 使蒙层不影响点击事件 */
  }
}

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