ArticlePage.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <el-row class="movie-list">
  3. <el-col :md="18">
  4. <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
  5. <el-card class="box-card" v-if="article !== null">
  6. <div slot="header" class="clearfix">
  7. <el-row>
  8. <span v-html="article.title" />
  9. <span v-if="article.originalUrl !== null">
  10. <a style="text-decoration-line: none" target="_blank" :href="`${article.originalUrl}`">
  11. 原始链接
  12. </a>
  13. </span>
  14. </el-row>
  15. <el-divider />
  16. <el-row>
  17. 发布于 <span v-html="article.publishAt" />
  18. </el-row>
  19. <el-divider />
  20. <el-row v-if="userAvatar !== null">
  21. <el-col :md="2">
  22. <router-link target="_blank" :to="`/user/` + userAvatar.userId">
  23. <el-avatar>
  24. <el-image :src="userAvatar.avatarUrl" />
  25. </el-avatar>
  26. </router-link>
  27. </el-col>
  28. <el-col :md="10">
  29. <el-row>
  30. <span v-html="userAvatar.screenName" />
  31. </el-row>
  32. <el-row>
  33. <span>-</span>
  34. </el-row>
  35. </el-col>
  36. </el-row>
  37. </div>
  38. <div class="text item">
  39. <el-row>
  40. <span v-html="article.content" />
  41. </el-row>
  42. <el-divider />
  43. <el-row>
  44. <span>
  45. <i :class="collectedIcon" @click="collectItem" />
  46. </span>
  47. </el-row>
  48. </div>
  49. </el-card>
  50. </el-row>
  51. </el-col>
  52. <el-col :md="6">
  53. <el-row style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px">
  54. <el-card class="box-card">
  55. <div slot="header" class="clearfix">
  56. <el-row>
  57. <span>推荐文章</span>
  58. </el-row>
  59. </div>
  60. <div class="text item">
  61. <el-row />
  62. </div>
  63. </el-card>
  64. </el-row>
  65. </el-col>
  66. </el-row>
  67. </template>
  68. <script>
  69. // import { getArticle } from '@/api/article'
  70. // import { getUserInfo } from '@/api/user'
  71. import { getNewsDetail } from '@/api/news'
  72. export default {
  73. name: 'ArticlePage',
  74. metaInfo: {
  75. meta: [
  76. { name: 'referrer', content: 'no-referrer' }
  77. ]
  78. },
  79. components: {},
  80. filters: {
  81. ellipsis(value) {
  82. if (!value) return ''
  83. const max = 20
  84. if (value.length > max) {
  85. return value.slice(0, max) + '...'
  86. }
  87. return value
  88. }
  89. },
  90. data() {
  91. return {
  92. article: null,
  93. userAvatar: null,
  94. collected: false,
  95. collectedIcon: 'el-icon-star-off'
  96. }
  97. },
  98. created() {
  99. const articleId = this.$route.params.articleId
  100. getNewsDetail(articleId).then(resp => {
  101. if (resp.code === 0) {
  102. this.article = resp.data
  103. document.title = '文章 - ' + this.article.title
  104. /* getUserInfo(this.article.userId).then(resp => {
  105. if (resp.code === 0) {
  106. this.userAvatar = resp.data
  107. }
  108. })*/
  109. }
  110. })
  111. },
  112. methods: {
  113. collectItem() {
  114. this.$message.info('暂未实现')
  115. if (this.collected) {
  116. console.log('取消收藏')
  117. this.collected = false
  118. this.collectedIcon = 'el-icon-star-off'
  119. } else {
  120. console.log('收藏')
  121. this.collected = true
  122. this.collectedIcon = 'el-icon-star-on'
  123. }
  124. }
  125. }
  126. }
  127. </script>
  128. <style scoped>
  129. /*处于手机屏幕时*/
  130. @media screen and (max-width: 768px) {
  131. .movie-list {
  132. padding-top: 5px;
  133. padding-left: 3px;
  134. padding-right: 3px;
  135. }
  136. }
  137. .movie-list {
  138. padding-top: 5px;
  139. padding-left: 3px;
  140. padding-right: 3px;
  141. }
  142. .clearfix:before,
  143. .clearfix:after {
  144. display: table;
  145. content: "";
  146. }
  147. .clearfix:after {
  148. clear: both;
  149. }
  150. </style>