not-cover.uvue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 not-cover"
  6. direction="column"
  7. >
  8. <view class="main">
  9. <view>
  10. <text class="title">{{ data?.title }}</text>
  11. </view>
  12. <view class="info">
  13. <text class="author">{{ data!.user_id!.length > 0 ? data!.user_id[0]!.nickname : '' }}</text>
  14. <text class="publish_date">{{ publishTime(data?.publish_date ?? 0) }}</text>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script lang="uts">
  20. import { type PropType } from 'vue'
  21. import translatePublishTime from "@/uni_modules/uni-cms-article/common/publish-time.uts";
  22. type ArticleAuthor = {
  23. _id: string
  24. nickname: string
  25. }
  26. type ArticleItem = {
  27. _id: string
  28. title: string
  29. publish_date: number
  30. thumbnail: string[]
  31. user_id: ArticleAuthor[]
  32. }
  33. export default {
  34. name: "not-cover",
  35. props: {
  36. data: {
  37. type: Object as PropType<ArticleItem>
  38. }
  39. },
  40. methods: {
  41. // 格式化时间戳
  42. publishTime(timestamp: number): string {
  43. return translatePublishTime(timestamp)
  44. },
  45. }
  46. }
  47. </script>
  48. <style scoped lang="scss">
  49. @import "./style.scss";
  50. </style>