<template>
  <div>
    <p class=" text-2xl font-bold mb-5 ">{{ title }}</p>
    <p class=" text-gray-400">发布时间：{{ time | format }} <span class=" ml-2">作者：{{ name }}</span></p>
    <div class="text-left p-5" v-html="content"></div>
    <!-- <p class="text-left p-5">{{content}}</p> -->
  </div>
</template>

<script lang="ts">
import Vue from 'vue'
import News from '@/service/News/index'
import Filter from '@/filter/index'

const news = new News()

export default Vue.extend({
  data(){
    return{
      title:'',
      time:'',
      name:'',
      content:''
    }
  },
  filters: {
    format(value: string) {
      return Filter.formatDate(value)
    }
  },
  methods: {
    getDetails() {
      const type = this.$route.query.type
      const uuid = this.$route.query.key as string
      const request = +type === 1 ? 'searchPolicy' : 'searchNews'
      news[request](uuid).then(res => {
        console.log(res)
        const { data } = res
        this.time = data.created_at
        this.name = data.writer
        this.content = data.content
        this.title = data.title
      })
    }
  },
  created() {
    this.getDetails()
  }
  
})
</script>