<template>
  <div
    class="full component-box"
    :style="`background-image: url(${state.img}); background-size: 100% 100%;`"
  >
    <div class="inBox">
      <div>
        <p class="title">工作记录</p>
        <ul class="blog-box">
          <li
            class="blog-item"
            v-for="item,$i in state.blogInfo.work.list"
            :key="$i"
          >
            <p class="ellips">
              <span :class="{'hot': $i<3}">{{$i+1}}</span>
              <span :title="item.title">{{item.title}}</span>
            </p>
            <p>{{item.date}} </p>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, onMounted, reactive } from 'vue'
import { getPortalBlog } from '../../../assets/api/api-blog'

export default defineComponent({
  name: 'blog',
  components: {},
  setup() {
    let state = reactive({
      img: require('../../../assets/image/bak-blog.jpg'),
      blogInfo: {
        work: { list: [] },
      },
    })

    getPortalBlog().then((res) => {
      state.blogInfo = JSON.parse(JSON.stringify(res))
    })

    onMounted(() => {
      console.log('Blog onmunted')
    })

    return {
      state,
    }
  },
})
</script>

<style lang="scss">
.component-box {
  .inBox {
    padding-top: 120px;
    padding-left: 300px;
    > div {
      width: 25%;
      float: left;
      margin-right: 4%;
      .title {
        height: 60px;
        line-height: 60px;
        background: #fff;
        text-align: center;
        margin-bottom: 20px;
        font-weight: bold;
        font-size: 20px;
      }
      .blog-box {
        // background: rgba(255, 255, 255, 0.6);
        li {
          height: 60px;
          // border-bottom: 1px dashed skyblue;
          > p span:nth-child(1) {
            line-height: 30px;
            height: 30px;
            width: 30px;
            display: inline-block;
            background: #fff;
            margin-right: 8px;
            border-radius: 0 50% 50% 0;
            text-align: center;
          }
          > p span:nth-child(2) {
            background: #fff;
            padding: 5px 0;
            width: 100%;
            border-radius: 14px 0 0 14px;
          }
          span.hot {
            color: red;
            font-weight: bold;
            background: #fff;
          }
        }
      }
    }
  }
}
</style>
