NewsDetailView.vue 4.1 KB

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