three-cover.uvue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view
  3. :to="'/uni_modules/uni-cms-article/pages/detail/detail?id=' + data?._id"
  4. :key="data?._id"
  5. class="list-item"
  6. direction="column"
  7. >
  8. <view class="main">
  9. <text class="title">{{ data?.title }}</text>
  10. <view class="thumbnails">
  11. <image
  12. v-for="image in data?.thumbnail"
  13. :src="image"
  14. mode="aspectFill"
  15. class="img"
  16. ></image>
  17. </view>
  18. <view class="info">
  19. <text class="author">{{ data!.user_id!.length > 0 ? data!.user_id[0]!.nickname : '' }}</text>
  20. <text class="publish_date">{{ publishTime(data?.publish_date ?? 0) }}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script lang="uts">
  26. import { type PropType } from 'vue'
  27. import translatePublishTime from "@/uni_modules/uni-cms-article/common/publish-time.uts";
  28. type ArticleAuthor = {
  29. _id: string
  30. nickname: string
  31. }
  32. type ArticleItem = {
  33. _id: string
  34. title: string
  35. publish_date: number
  36. thumbnail: string[]
  37. user_id: ArticleAuthor[]
  38. }
  39. export default {
  40. name: "three-cover",
  41. props: {
  42. data: {
  43. type: Object as PropType<ArticleItem>
  44. }
  45. },
  46. methods: {
  47. // 格式化时间戳
  48. publishTime(timestamp: number): string {
  49. return translatePublishTime(timestamp)
  50. },
  51. }
  52. }
  53. </script>
  54. <style scoped lang="scss">
  55. @import "./style.scss";
  56. </style>