ArticlePage.vue 2.4 KB

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