<template>
  <div
    class="home"
  >
    <div class="containers">
      <h1 class="title">
        {{ $gConfigInfo.title }}
      </h1>

      <ul>
        <li
          v-for="item in Object.entries($gConfigInfo.objInfo).slice(pageSize * (currentPage - 1), pageSize * currentPage)"
          :key="item[0]"
          @click="onClickItem(item)"
        >
          <img
            class=""
            :src="`${$env.BASE_URL}user-config/images/${item[0]}.jpg`"
            alt=""
            draggable="false"
          >
          <div class="title">
            {{ item[1] }}
          </div>
        </li>
      </ul>

      <el-pagination
        v-model:current-page="currentPage"
        v-model:page-size="pageSize"
        class="pagination"
        :page-sizes="[10, 20, 50, 100]"
        background
        layout="total, sizes, prev, pager, next, jumper"
        :total="Object.keys($gConfigInfo.objInfo).length"
      />
    </div>
  </div>
</template>

<script>
export default {
  name: 'HomeView',
  data() {
    return {
      currentPage: 1,
      pageSize: 10,
    }
  },
  computed: {
    ...mapState([
    ]),
  },
  mounted() {
    console.log(process.env)
    this.$mitt.emit('test', { msg: 'home mounted' })
  },
  unmounted() {
  },
  methods: {
    ...mapMutations([
    ]),
    onClickItem(item) {
      this.$router.push({
        name: 'RelicDetail',
        query: {
          m: item[0],
        }
      })
    }
  },
}
</script>

<style lang="less" scoped>
.home {
  width: 100%;
  height: 100%;
  .containers {
    padding-top: 40px;
    width: 100vw;
    max-width: 1080px;
    /* height: 100vh; */
    background-color: #285b5e;
    /* overflow: hidden; */
    height: 100%;
    margin: 0 auto;
    padding-bottom: 50px;
    position: relative;
    > .title {
      letter-spacing: 4px;
      margin: 0 auto;
      color: #fff;
      display: flex;
      justify-content: center;
      align-items: center;
      width: 270px;
      height: 50px;
      background: url('@/assets/images/titleBac.png') no-repeat center;
      background-size: 100% 100%;
    }
    > ul {
      width: 100%;
      height: calc(100% - 80px);
      padding-top: 30px;
      padding-left: 20px;
      display: flex;
      flex-wrap: wrap;
      align-content: start;
      overflow: auto;
      > li {
        display: inline-block;
        width: calc((100% - 20px * 4) / 3 - 1px);
        margin-right: 20px;
        margin-bottom: 20px;
        cursor: pointer;
        transition: all 0.3s;
        &:hover {
          transform: translateY(-10px);
        }
        > img {
          width: 100%;
          padding: 10px;
          background: url(@/assets/images/divBac.png);
          background-size: 100% 100%;
          box-shadow: 1px 1px 5px rgba(0, 0, 0, 0.4);
        }
        > .title {
          color: #fff;
          margin-top: 10px;
          font-size: 16px;
          font-weight: 100;
          text-align: center;
        }
      }
    }
    .pagination {
      position: absolute;
      left: 50%;
      bottom: 10px;
      transform: translateX(-50%);
    }
  }
}

@media screen and (max-width: 600px) {
}
</style>