detail.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <!-- 资讯详情页 -->
  3. <div class="main-background">
  4. <div class="nav-placeholder"></div>
  5. <!-- SEO -->
  6. <Head>
  7. <Title>{{ newsLoader.content.value?.title }}</Title>
  8. <Meta name="description" :content="newsLoader.content.value?.desc" />
  9. </Head>
  10. <!-- 新闻 -->
  11. <section class="main-section main-background main-background-type0 small-h">
  12. <SimplePageContentLoader :loader="newsLoader">
  13. <div v-if="newsLoader.content.value" class="content news-detail">
  14. <div class="d-flex flex-row justify-content-start">
  15. <div class="back-button2" @click="back">
  16. <img src="@/assets/images/news/IconBack.png" />
  17. <span>返回列表</span>
  18. </div>
  19. </div>
  20. <h1>{{ newsLoader.content.value.title }}</h1>
  21. <div class="d-flex flex-row justify-content-center gap-3" >
  22. <span v-if="newsLoader.content.value.from" class="small-info">来源:{{ newsLoader.content.value.from }}</span>
  23. <span v-if="newsLoader.content.value.regionText" class="small-info">区域:{{ newsLoader.content.value.regionText }}</span>
  24. <span class="small-info">时间:{{ DateUtils.formatDate(newsLoader.content.value.publishAt, DateUtils.FormatStrings.ShortDate) }}</span>
  25. </div>
  26. <video
  27. v-if="newsLoader.content.value.audio"
  28. class="news-video mt-3"
  29. controls
  30. :src="newsLoader.content.value.audio"
  31. />
  32. <video
  33. v-else-if="newsLoader.content.value.video"
  34. class="news-video mt-3"
  35. controls
  36. :src="newsLoader.content.value.video"
  37. />
  38. <iframe
  39. v-if="newsLoader.content.value.archives"
  40. class="w-100 mt-3"
  41. :style="{ height: '90vh' }"
  42. :src="(newsLoader.content.value.archives as string)"
  43. />
  44. <SimpleRichHtml
  45. class="news-content mt-3"
  46. :contents="[
  47. newsLoader.content.value.intro,
  48. newsLoader.content.value.value,
  49. newsLoader.content.value.content,
  50. ]"
  51. >
  52. <template #prepend>
  53. <!-- 轮播 -->
  54. <Carousel
  55. v-if="!newsLoader.content.value.video && !newsLoader.content.value.audio && newsLoader.content.value.images.length > 0"
  56. :itemsToShow="1"
  57. wrapAround
  58. :autoPlay="5000"
  59. :class="[
  60. 'carousel large',
  61. //!newsLoader.content.value.content ? 'large' : 'float',
  62. ]"
  63. >
  64. <Slide v-for="(image, key) in newsLoader.content.value.images" :key="key">
  65. <img :src="image" />
  66. </Slide>
  67. <template #addons>
  68. <Navigation />
  69. <Pagination />
  70. </template>
  71. </Carousel>
  72. </template>
  73. </SimpleRichHtml>
  74. <div class="row d-flex justify-content-center">
  75. <div class="back-button" @click="back">
  76. <img src="@/assets/images/news/IconBack.png" />
  77. <span>返回列表</span>
  78. </div>
  79. </div>
  80. <ContentNode />
  81. <!-- <div class="row pt-3 pt-md-4 pt-lg-5">
  82. <div class="col-12 col-md-6 col-lg-6 col-xl-6 d-flex justify-content-start">
  83. <span class="small-info">上一篇:????</span>
  84. </div>
  85. <div class="col-12 col-md-6 col-lg-6 col-xl-6 d-flex justify-content-end">
  86. <span class="small-info">下一篇:????</span>
  87. </div>
  88. </div> -->
  89. </div>
  90. </SimplePageContentLoader>
  91. </section>
  92. </div>
  93. </template>
  94. <script setup lang="ts">
  95. import { Carousel, Slide, Pagination, Navigation } from 'vue3-carousel'
  96. import type { GetContentDetailItem } from '@/api/CommonContent';
  97. import NewsIndexContent from '@/api/news/NewsIndexContent';
  98. import { DateUtils } from '@imengyu/imengyu-utils';
  99. import SimplePageContentLoader from '@/components/content/SimplePageContentLoader.vue';
  100. import SimpleRichHtml from '@/components/display/SimpleRichHtml.vue';
  101. import { useSSrSimpleDataLoader } from '@/composeable/SimpleDataLoader';
  102. import { useRouter } from 'vue-router';
  103. import ContentNode from '@/components/content/ContentNode.vue';
  104. const route = useRoute();
  105. const router = useRouter();
  106. const newsLoader = await useSSrSimpleDataLoader('detail', async () => {
  107. const id = Number(route.query.id);
  108. const modelId = route.query.modelId ? Number(route.query.modelId) : undefined;
  109. if (!id)
  110. throw new Error('参数错误');
  111. const z = (await NewsIndexContent.getContentDetail<GetContentDetailItem>(id, modelId)).toJSON();
  112. //console.log(z);
  113. return z;
  114. }, false)
  115. function back() {
  116. router.back();
  117. }
  118. </script>