|
| 1 | +<template> |
| 2 | + <div class="article-detailed"> |
| 3 | + <div class="title">{{chapter.title}}</div> |
| 4 | + <div class="sub-info"> |
| 5 | + <div class="item"> |
| 6 | + <c-icon type="icon-book" /> |
| 7 | + <span class="text">{{chapter.novelName}}</span> |
| 8 | + </div> |
| 9 | + <div class="item"> |
| 10 | + <c-icon type="icon-antd-user" /> |
| 11 | + <span class="text">{{chapter.authorName}}</span> |
| 12 | + </div> |
| 13 | + <div class="item"> |
| 14 | + <c-icon type="icon-clock" /> |
| 15 | + <span class="text">{{formatTime(chapter.updateTime * 1000, 'yyyy-MM-dd')}}</span> |
| 16 | + </div> |
| 17 | + <div class="item" v-if="chapter.viewCount > 0"> |
| 18 | + <c-icon type="icon-antd-fire" /> |
| 19 | + <span class="text">{{chapter.viewCount}}</span> |
| 20 | + </div> |
| 21 | + </div> |
| 22 | + <div |
| 23 | + class="article-content" |
| 24 | + v-html="marked(chapter.content)"></div> |
| 25 | + <div class='pager'> |
| 26 | + <div class='item' v-if="chapter.preId"> |
| 27 | + <router-link class='item-text' :to="`/chapterdetail?id=${chapter.preId}`"> |
| 28 | + 上一章 |
| 29 | + </router-link> |
| 30 | + </div> |
| 31 | + <div class='item'> |
| 32 | + <router-link class='item-text' :to="`/noveldetail?id=${chapter.novelId}`"> |
| 33 | + 目录 |
| 34 | + </router-link> |
| 35 | + </div> |
| 36 | + <div class='item' v-if="chapter.nextId"> |
| 37 | + <router-link class='item-text' :to="`/chapterdetail?id=${chapter.nextId}`"> |
| 38 | + 下一章 |
| 39 | + </router-link> |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + <div class="comment-wrapper"> |
| 43 | + <div class="divider">评论</div> |
| 44 | + <c-comment type="novel" :id="chapter.id" /> |
| 45 | + </div> |
| 46 | + </div> |
| 47 | +</template> |
| 48 | + |
| 49 | +<script> |
| 50 | +import Comment from '@/components/Comment' |
| 51 | +import Icon from './Icon' |
| 52 | +import { formatTime } from '../assets/js/tools' |
| 53 | +
|
| 54 | +const renderer = new marked.Renderer() |
| 55 | +marked.setOptions({ |
| 56 | + renderer: renderer, |
| 57 | + gfm: true, |
| 58 | + pedantic: false, |
| 59 | + sanitize: false, |
| 60 | + tables: true, |
| 61 | + breaks: true, |
| 62 | + smartLists: true, |
| 63 | + smartypants: false, |
| 64 | + highlight: function(code){ |
| 65 | + return hljs.highlightAuto(code).value; |
| 66 | + } |
| 67 | +}) |
| 68 | +
|
| 69 | +export default { |
| 70 | + components: { |
| 71 | + 'c-comment': Comment, |
| 72 | + 'c-icon': Icon |
| 73 | + }, |
| 74 | + props: { |
| 75 | + chapter: { |
| 76 | + type: Object, |
| 77 | + required: true |
| 78 | + } |
| 79 | + }, |
| 80 | + methods: { |
| 81 | + formatTime, |
| 82 | + marked |
| 83 | + }, |
| 84 | +} |
| 85 | +</script> |
| 86 | + |
| 87 | +<style lang="scss" scoped> |
| 88 | +.article-detailed { |
| 89 | + background-color: #fff; |
| 90 | + margin-top: 1rem; |
| 91 | + padding: 1rem; |
| 92 | + text-align: center; |
| 93 | + .title { |
| 94 | + font-size: 1.4rem; |
| 95 | + color: #333333; |
| 96 | + padding: .5rem 0; |
| 97 | + } |
| 98 | + .sub-info { |
| 99 | + display: flex; |
| 100 | + justify-content: center; |
| 101 | + padding: 1rem 0; |
| 102 | + .reprint { |
| 103 | + color: #74cf59; |
| 104 | + margin-right: 2rem; |
| 105 | + padding: .25rem .5rem; |
| 106 | + background-color: #eaf9e3; |
| 107 | + } |
| 108 | + .orginal { |
| 109 | + color: #ca0c16; |
| 110 | + background-color: #f9ecec; |
| 111 | + } |
| 112 | + .item { |
| 113 | + font-size: 1rem; |
| 114 | + color: #999999; |
| 115 | + padding-right: 2rem; |
| 116 | + .text { |
| 117 | + font-size: .9rem; |
| 118 | + margin-left: .5rem; |
| 119 | + } |
| 120 | + } |
| 121 | + } |
| 122 | + .article-content { |
| 123 | + text-align: left; |
| 124 | + padding: 1rem; |
| 125 | + font-size: 1rem; |
| 126 | + & /deep/ img { |
| 127 | + width: 100%; |
| 128 | + padding: 1rem 0; |
| 129 | + } |
| 130 | + } |
| 131 | + .pager { |
| 132 | + display: flex; |
| 133 | + align-items: center; |
| 134 | + margin: 1rem 0 2rem; |
| 135 | + padding: .5rem 0; |
| 136 | + .item { |
| 137 | + flex: 1; |
| 138 | + margin: 0 .5rem; |
| 139 | + padding: .5rem 0; |
| 140 | + background-color: #eaeaea; |
| 141 | + border-radius: .25rem; |
| 142 | + .item-text { |
| 143 | + padding: .5rem 1rem; |
| 144 | + font-size: 1.2rem; |
| 145 | + color: #333333 !important; |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | + .comment-wrapper { |
| 150 | + .divider { |
| 151 | + font-size: 1rem; |
| 152 | + color: #999999; |
| 153 | + margin: 1rem .5rem; |
| 154 | + padding: .5rem 0; |
| 155 | + border-bottom: 1px solid #dddddd; |
| 156 | + letter-spacing: .5rem; |
| 157 | + } |
| 158 | + } |
| 159 | + /* 美化markdown */ |
| 160 | + & /deep/ pre{ |
| 161 | + display: block; |
| 162 | + background-color: #283646; |
| 163 | + padding: .5rem !important; |
| 164 | + overflow-y: auto; |
| 165 | + font-weight: 300; |
| 166 | + font-family: Menlo, monospace; |
| 167 | + border-radius: .3rem; |
| 168 | + } |
| 169 | + & /deep/ pre > code{ |
| 170 | + border:0px !important; |
| 171 | + background-color: #283646 !important; |
| 172 | + color:#FFF; |
| 173 | + } |
| 174 | + & /deep/ code { |
| 175 | + color: #c7254e; |
| 176 | + background-color: #f9f2f4; |
| 177 | + border-radius: 4px; |
| 178 | + font-size: 12px; |
| 179 | + padding-left: 5px; |
| 180 | + padding-right: 5px; |
| 181 | + margin: 0px 3px; |
| 182 | + width: calc(100% - 10px); |
| 183 | + box-sizing: border-box; |
| 184 | + } |
| 185 | +} |
| 186 | +</style> |
0 commit comments