NewsDetailView.vue 4.3 KB

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