ArticlePage.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <el-row class="movie-list">
  3. <el-col :md="18">
  4. <el-row class="movie-list">
  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. </el-row>
  10. <el-divider />
  11. <el-row>
  12. <span v-html="article.publishAt" />
  13. </el-row>
  14. </div>
  15. <div class="text item">
  16. <el-row>
  17. <span v-html="article.content" />
  18. </el-row>
  19. <el-divider />
  20. <el-row>
  21. </el-row>
  22. </div>
  23. </el-card>
  24. </el-row>
  25. </el-col>
  26. <el-col :md="6">
  27. <el-row class="movie-list">
  28. <el-card class="box-card">
  29. <div slot="header" class="clearfix">
  30. <el-row>
  31. <span>推荐文章</span>
  32. </el-row>
  33. </div>
  34. <div class="text item">
  35. <el-row />
  36. </div>
  37. </el-card>
  38. </el-row>
  39. </el-col>
  40. </el-row>
  41. </template>
  42. <script>
  43. // import { getArticle } from '@/api/article'
  44. // import { getUserInfo } from '@/api/user'
  45. import { getPost, getNewsDetail } from '@/api/blog'
  46. export default {
  47. name: 'ArticlePage',
  48. metaInfo: {
  49. meta: [
  50. { name: 'referrer', content: 'no-referrer' }
  51. ]
  52. },
  53. components: {},
  54. filters: {
  55. ellipsis(value) {
  56. if (!value) return ''
  57. const max = 20
  58. if (value.length > max) {
  59. return value.slice(0, max) + '...'
  60. }
  61. return value
  62. }
  63. },
  64. data() {
  65. return {
  66. article: null,
  67. userAvatar: null,
  68. collected: false,
  69. collectedIcon: 'el-icon-star-off'
  70. }
  71. },
  72. created() {
  73. const articleId = this.$route.params.articleId
  74. this.getData(articleId)
  75. },
  76. methods: {
  77. getData(articleId) {
  78. getPost(articleId).then(resp => {
  79. if (resp.code === 0) {
  80. this.article = resp.data
  81. document.title = this.article.title
  82. }
  83. })
  84. },
  85. collectItem() {
  86. this.$message.info('暂未实现')
  87. if (this.collected) {
  88. console.log('取消收藏')
  89. this.collected = false
  90. this.collectedIcon = 'el-icon-star-off'
  91. } else {
  92. console.log('收藏')
  93. this.collected = true
  94. this.collectedIcon = 'el-icon-star-on'
  95. }
  96. }
  97. }
  98. }
  99. </script>
  100. <style scoped>
  101. /*处于手机屏幕时*/
  102. @media screen and (max-width: 768px) {
  103. .movie-list {
  104. padding: 5px;
  105. }
  106. }
  107. .movie-list {
  108. padding: 5px;
  109. }
  110. .clearfix:before,
  111. .clearfix:after {
  112. display: table;
  113. content: "";
  114. }
  115. .clearfix:after {
  116. clear: both;
  117. }
  118. </style>