<template>
  <div @click="$router.push({path: 'NewsDetail', query: { uuid: info.uuid, type: 'policy' }})">
    <div class=" text-base text-gray-800 font-semibold pt-5 news-title">{{ info.title }}</div>
    <!-- <p class=" text-xs text-gray-400 pt-5">{{ info.desc }}</p> -->
    <div class=" text-sm text-gray-800 text-justify pt-3 news-info">{{ info.desc }}</div>
    <div
      v-if="showImg"
      class=" h-32 bg-app-blue mt-2 bg-cover bg-center bg-no-repeat"
      :style="{'background-image': `url('${url}')`}"></div>
    <div class=" text-xs text-gray-400 py-5 border-b border-red border-solid">发布时间：{{ $format(info.update_at, 'YYYY-MM-DD') }} &nbsp;&nbsp;&nbsp;作者: {{ info.writer }}</div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import { getImageSrcFromFileHash } from '@/service/FileService/index'

export default defineComponent({
  props: {
    info: {
      type: Object
    },
    showImg:{
      type:Boolean,
      default:true
    },
  },
  setup (props) {
    const url = ref('')
    url.value = getImageSrcFromFileHash((props.info as {file_name: string})?.file_name)

    return {
      url
    }
  }
})
</script>

<style scoped>

  .news-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
  }
  .news-info {
    display: -webkit-box;
    overflow: hidden;  
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
  }
</style>