articleRight.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <!-- 文章右部分 -->
  2. <template>
  3. <div class="right_wrap">
  4. <!-- 分类列表显示 -->
  5. <div class="nch_article_con" v-if="!showContent">
  6. <div class="title_bar">
  7. <h3>{{ title }}</h3>
  8. </div>
  9. <!-- 分类显示 -->
  10. <ul class="nch_article_list">
  11. <li v-for="(item, index) in cate" :key="index">
  12. <i></i>
  13. <a @click="getContent(item.articleId)" style="cursor: pointer">{{
  14. item.title
  15. }}</a>
  16. <time></time>
  17. </li>
  18. </ul>
  19. </div>
  20. <!-- 文章内容显示 -->
  21. <div v-if="showContent">
  22. <h2 v-html="data.articeContent.title" class="article_title"></h2>
  23. <!-- <p v-html="data.articeContent.createTime" class="article_time"></p> -->
  24. <div class="article_content ql-container">
  25. <div class="ql-editor" v-html="data.articeContent.content"></div>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script setup>
  31. import { reactive, getCurrentInstance, onMounted, ref, watchEffect } from "vue";
  32. import { getCurLanguage } from '@/composables/common.js';
  33. const L = getCurLanguage();
  34. defineProps(["cate", "title"]);
  35. const route = useRoute();
  36. const router = useRouter();
  37. const { proxy } = getCurrentInstance();
  38. const data = reactive({
  39. articeContent: {},
  40. });
  41. const showContent = ref(false); //单独声明showContent以便引用
  42. const childMethod = (val) => {
  43. showContent.value = false;
  44. }
  45. //通过articleId获取文章详情
  46. const getContent = (articleId) => {
  47. const params = {
  48. articleId: articleId,
  49. };
  50. get("v3/cms/front/article/articleDetail", params).then((res) => {
  51. if (res.state === 200) {
  52. if (res.data.outUrl) {
  53. window.open(res.data.outUrl,'_blank');
  54. return
  55. }
  56. if (res.data.content) {
  57. res.data.content = quillEscapeToHtml(res.data.content);
  58. }
  59. data.articeContent = res.data;
  60. showContent.value = true;
  61. }
  62. });
  63. };
  64. defineExpose({ childMethod,getContent});
  65. onMounted(() => {
  66. if (route.query.articleId) {
  67. getContent(route.query.articleId);
  68. }
  69. });
  70. watchEffect(() => {
  71. if (route.query.articleId) {
  72. getContent(route.query.articleId);
  73. }
  74. });
  75. </script>
  76. <style lang="scss" scoped>
  77. @import "@/assets/style/vendors.css";
  78. .right_wrap {
  79. flex: 1;
  80. width: 100%;
  81. overflow: auto;
  82. height: 100%;
  83. background: #fff;
  84. // padding: 0 50px;
  85. .nch_article_con {
  86. display: block;
  87. padding: 19px 50px;
  88. margin: 0 auto 10px;
  89. overflow: hidden;
  90. .title_bar {
  91. border-bottom: solid 1px #e6e6e6;
  92. padding-bottom: 15px;
  93. margin-bottom: 15px;
  94. h3 {
  95. font: normal 18px/20px "microsoft yahei";
  96. }
  97. }
  98. .nch_article_list li {
  99. line-height: 20px;
  100. display: block;
  101. height: 30px;
  102. padding: 5px 0;
  103. i {
  104. background: #555555;
  105. vertical-align: middle;
  106. display: inline-block;
  107. width: 3px;
  108. height: 3px;
  109. margin-right: 10px;
  110. }
  111. a {
  112. color: #666;
  113. word-break: break-all;
  114. }
  115. }
  116. }
  117. .article_title {
  118. text-align: center;
  119. font-size: 24px;
  120. line-height: 24px;
  121. margin-top: 20px;
  122. margin-bottom: 20px;
  123. }
  124. .article_time {
  125. font-size: 16px;
  126. text-align: center;
  127. line-height: 40px;
  128. color: #666;
  129. margin-bottom: 20px;
  130. }
  131. .article_content {
  132. padding: 0 20px;
  133. word-break: break-all;
  134. .ql-editor {
  135. padding: 0;
  136. }
  137. }
  138. }
  139. </style>
  140. <style lang="scss">
  141. .right_wrap {
  142. .article_content {
  143. img {
  144. max-width: 900px;
  145. }
  146. a {
  147. display: inline-block;
  148. margin: 5px auto;
  149. color: #0000ff;
  150. text-decoration: underline;
  151. }
  152. table {
  153. border-collapse: collapse;
  154. padding: 0;
  155. }
  156. td,
  157. th {
  158. border: 1px solid #ddd;
  159. padding: 5px 10px;
  160. }
  161. ol li,
  162. ul li {
  163. list-style: unset;
  164. }
  165. }
  166. }
  167. </style>