NewsDetailView.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <!-- 资讯详情页 -->
  3. <div class="main-background">
  4. <div class="nav-placeholder"></div>
  5. <!-- 新闻 -->
  6. <section class="main-section main-background main-background-type0">
  7. <SimplePageContentLoader :loader="newsLoader">
  8. <div v-if="newsLoader.content.value" class="content news-detail">
  9. <h1>{{ newsLoader.content.value.title }}</h1>
  10. <div class="row p-2 p-md-3 p-lg-4">
  11. <div class="col-12 col-md-4 col-lg-4 col-xl-4 d-flex justify-content-center">
  12. <span class="small-info">作者:{{ newsLoader.content.value.author || '管理员' }}</span>
  13. </div>
  14. <div class="col-12 col-md-4 col-lg-4 col-xl-4 d-flex justify-content-center">
  15. <span class="small-info">时间:{{ DateUtils.formatDate(newsLoader.content.value.publish_at, DateUtils.FormatStrings.YearCommon) }}</span>
  16. </div>
  17. <div class="col-12 col-md-4 col-lg-4 col-xl-4 d-flex justify-content-center">
  18. <span class="small-info">浏览量:{{ newsLoader.content.value.views }}</span>
  19. </div>
  20. </div>
  21. <video
  22. v-if="newsLoader.content.value.audio"
  23. class="news-video mt-3"
  24. controls
  25. :src="newsLoader.content.value.audio"
  26. />
  27. <video
  28. v-else-if="newsLoader.content.value.video"
  29. class="news-video mt-3"
  30. controls
  31. :src="newsLoader.content.value.video"
  32. />
  33. <!-- 轮播 -->
  34. <Carousel
  35. v-else
  36. :itemsToShow="1"
  37. wrapAround
  38. :autoPlay="5000"
  39. class="carousel"
  40. >
  41. <Slide v-for="(image, key) in newsLoader.content.value.images" :key="key">
  42. <img :src="image" />
  43. </Slide>
  44. <template #addons>
  45. <Navigation />
  46. <Pagination />
  47. </template>
  48. </Carousel>
  49. <SimpleRichHtml
  50. class="news-content mt-3"
  51. :contents="[
  52. newsLoader.content.value.intro,
  53. newsLoader.content.value.value,
  54. newsLoader.content.value.content,
  55. ]"
  56. />
  57. <div class="row d-flex justify-content-center">
  58. <div class="back-button" @click="back">
  59. <img src="@/assets/images/news/IconBack.png" />
  60. <span>返回列表</span>
  61. </div>
  62. </div>
  63. <!-- <div class="row pt-3 pt-md-4 pt-lg-5">
  64. <div class="col-12 col-md-6 col-lg-6 col-xl-6 d-flex justify-content-start">
  65. <span class="small-info">上一篇:????</span>
  66. </div>
  67. <div class="col-12 col-md-6 col-lg-6 col-xl-6 d-flex justify-content-end">
  68. <span class="small-info">下一篇:????</span>
  69. </div>
  70. </div> -->
  71. </div>
  72. </SimplePageContentLoader>
  73. </section>
  74. </div>
  75. </template>
  76. <script setup lang="ts">
  77. import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel'
  78. import type { GetContentDetailItem } from '@/api/CommonContent';
  79. import NewsIndexContent from '@/api/news/NewsIndexContent';
  80. import DateUtils from '@/common/utils/DateUtils';
  81. import SimplePageContentLoader from '@/components/content/SimplePageContentLoader.vue';
  82. import SimpleRichHtml from '@/components/display/SimpleRichHtml.vue';
  83. import { useLoadQuerys } from '@/composeable/PageQuerys';
  84. import { useSimpleDataLoader } from '@/composeable/SimpleDataLoader';
  85. import { useRouter } from 'vue-router';
  86. const router = useRouter();
  87. const newsLoader = useSimpleDataLoader<GetContentDetailItem, {
  88. id: number,
  89. modelId: number,
  90. }>(async (p) => {
  91. if (!p)
  92. throw new Error('参数错误');
  93. return (await NewsIndexContent.getContentDetail<GetContentDetailItem>(p.id, p.modelId ? p.modelId : undefined));
  94. }, false)
  95. useLoadQuerys({
  96. id: 0,
  97. modelId: 0,
  98. }, async (p) => {
  99. if (p.id <= 0) {
  100. router.push({ name: 'NotFound' });
  101. return;
  102. }
  103. newsLoader.loadData(p);
  104. })
  105. function back() {
  106. router.back();
  107. }
  108. </script>