Skip to content

Commit db7b12d

Browse files
committed
fix[article,bookNote]:添加contentFormat字段
1 parent a70772e commit db7b12d

File tree

11 files changed

+37
-31
lines changed

11 files changed

+37
-31
lines changed

dbblog-backend/dbblog-core/src/main/java/cn/dblearn/blog/entity/article/Article.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,7 @@ public class Article implements Serializable {
7979
@ApiModelProperty(value = "是否置顶")
8080
private Boolean top;
8181

82+
@ApiModelProperty(value = "格式化后的内容")
83+
private String contentFormat;
84+
8285
}

dbblog-backend/dbblog-core/src/main/java/cn/dblearn/blog/entity/book/BookNote.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public class BookNote implements Serializable {
8585
@ApiModelProperty(value = "是否置顶")
8686
private Boolean top;
8787

88-
88+
@ApiModelProperty(value = "格式化后的内容")
89+
private String contentFormat;
8990

9091
}

dbblog-frontend/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dbblog-frontend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"axios": "0.17.1",
1818
"highlight.js": "^9.12.0",
1919
"iview": "^2.14.2",
20-
"marked": "^0.5.2",
2120
"mavon-editor": "^2.4.16",
2221
"stylus": "^0.54.5",
2322
"stylus-loader": "^3.0.1",

dbblog-frontend/src/common/stylus/article.styl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,24 +240,24 @@ article#article-main-page
240240
padding 4px 5px 4px 12px
241241
margin 15px 0
242242
word-wrap break-word
243-
border-left 5px solid $default-desc-hover-color
243+
border-left .25em solid $default-info-color
244244
background $default-border-color
245245
@media only screen and (max-width: $responsive-sm)
246246
padding-left 5px
247247
margin 8px 0
248-
border-left 2px solid $default-desc-hover-color
248+
border-left .25em solid $default-desc-hover-color
249249
@media screen and (min-width: $responsive-sm)
250250
padding-left 8px
251251
margin 10px 0
252-
border-left 3px solid $default-desc-hover-color
252+
border-left .25em solid $default-info-color
253253
@media screen and (min-width: $responsive-md)
254254
padding-left 10px
255255
margin 12px 0
256-
border-left 4px solid $default-desc-hover-color
256+
border-left .25em solid $default-info-color
257257
@media screen and (min-width: $responsive-lg)
258258
padding-left 12px
259259
margin 15px 0
260-
border-left 5px solid $default-desc-hover-color
260+
border-left .25em solid $default-info-color
261261
> p
262262
font-weight 300
263263
color $default-info-color

dbblog-frontend/src/components/content/ArticleContent.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="layout-left">
66
<article-page-header :article="article"></article-page-header>
77
<article-page-content>
8-
<article id="article-main-page" class="typo container" slot="content" ref="article" v-html="article.content">
8+
<article id="article-main-page" class="typo container" slot="content" ref="article" v-html="article.contentFormat">
99
</article>
1010
</article-page-content>
1111
<article-page-footer :likeNum="article.likeNum" :commentList="article.commentList"></article-page-footer>
@@ -31,7 +31,6 @@ import FriendLinks from '@/components/views/FriendLinks'
3131
import SideToc from '@/components/views/SideToc'
3232
import Recommend from '@/components/views/Recommend'
3333
import TOC from '@/common/js/MarkdownToc'
34-
import marked from 'marked'
3534
// highlight.js引入
3635
import hljs from 'highlight.js'
3736
// 样式文件
@@ -76,8 +75,6 @@ export default {
7675
}).then(({data}) => {
7776
if (data && data.code === 200) {
7877
this.article = data.article
79-
// 将markdown语法解析成html
80-
this.article.content = marked(data.article.content)
8178
// 更新目录、高亮代码
8279
this.$nextTick(function () {
8380
this.addCodeLineNumber()

dbblog-frontend/src/components/content/BookNoteContent.vue

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="layout-left">
66
<bookNote-page-header :bookNote="bookNote"></bookNote-page-header>
77
<bookNote-page-content>
8-
<article id="bookNote-main-page" class="typo container" slot="content" ref="bookNote" v-html="bookNote.content">
8+
<article id="article-main-page" class="typo container" slot="content" ref="article" v-html="bookNote.contentFormat">
99
</article>
1010
</bookNote-page-content>
1111
<bookNote-page-footer :likeNum="bookNote.likeNum" :commentList="bookNote.commentList"></bookNote-page-footer>
@@ -31,7 +31,6 @@ import FriendLinks from '@/components/views/FriendLinks'
3131
import SideToc from '@/components/views/SideToc'
3232
import Recommend from '@/components/views/Recommend'
3333
import TOC from '@/common/js/MarkdownToc'
34-
import marked from 'marked'
3534
// highlight.js引入
3635
import hljs from 'highlight.js'
3736
// 样式文件
@@ -62,7 +61,7 @@ export default {
6261
methods: {
6362
addCodeLineNumber () {
6463
// 添加行号
65-
let blocks = this.$refs.bookNote.querySelectorAll('pre code')
64+
let blocks = this.$refs.article.querySelectorAll('pre code')
6665
blocks.forEach((block) => {
6766
HLJS.highlightBlock(block)
6867
// 去前后空格并添加行号
@@ -76,8 +75,6 @@ export default {
7675
}).then(({data}) => {
7776
if (data && data.code === 200) {
7877
this.bookNote = data.bookNote
79-
// 将markdown语法解析成html
80-
this.bookNote.content = marked(data.bookNote.content)
8178
// 更新目录、高亮代码
8279
this.$nextTick(function () {
8380
this.addCodeLineNumber()
@@ -89,29 +86,29 @@ export default {
8986
},
9087
refreshDiectory () {
9188
/* eslint-disable*/
92-
new TOC('bookNote-main-page', {
89+
new TOC('article-main-page', {
9390
'level': 5,
9491
'top': 200,
9592
'class': 'list',
9693
'targetId': 'side-toc'
9794
})
9895
/* eslint-disable */
99-
new TocScrollSpy('bookNote-main-page', 'side-toc', {
96+
new TocScrollSpy('article-main-page', 'side-toc', {
10097
'spayLevel': 5,
101-
'bookNoteMarginTop': 60
98+
'articleMarginTop': 60
10299
});
103100
},
104101
refreshMobileDirectory () {
105102
/* eslint-disable */
106-
new TOC('bookNote-main-page', {
103+
new TOC('article-main-page', {
107104
'level': 5,
108105
'top': 200,
109106
'class': 'list',
110107
'targetId': 'sidebar-toc'
111108
});
112-
new TocScrollSpy('bookNote-main-page', 'sidebar-toc', {
109+
new TocScrollSpy('article-main-page', 'sidebar-toc', {
113110
'spayLevel': 5,
114-
'bookNoteMarginTop': 60
111+
'articleMarginTop': 60
115112
});
116113
}
117114
}

dbblog-frontend/src/components/views/Book/BookReadingCell.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="book-reading-cell">
33
<h4>正在阅读</h4>
4-
<a>
4+
<a >
55
<div class="img">
66
<div class="container">
77
<div class="bracket"></div>
@@ -82,16 +82,14 @@ export default {
8282
flex 0 0 140px
8383
width 140px
8484
overflow hidden
85+
margin 0 30px 10px 0
8586
border 1px solid $default-border-hover-color
8687
box-shadow 1px 1px 1px $default-border-color
8788
@media only screen and (max-width: $responsive-sm)
88-
display block
89-
margin 0 15px 5px 0
89+
display none
9090
@media screen and (min-width: $responsive-sm)
91-
display block
92-
margin 0 20px 7px 0
91+
display none
9392
@media screen and (min-width: $responsive-lg)
94-
margin 0 30px 10px 0
9593
display block
9694
.container
9795
width 100%

dbblog-frontend/src/components/views/Recommend.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="recommend">
33
<panel :title="'推荐阅读'">
44
<div slot="content" class="content">
5-
<div class="top">
5+
<div class="top" v-if="topRecommend">
66
<a :href="'/' + topRecommend.urlType + '/' + topRecommend.linkId">
77
<p class="title">{{topRecommend.title}}</p>
88
<div class="tags">

dbblog-manage-frontend/src/views/modules/article/article-add-or-update.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</el-col>
8181
</el-form-item>
8282
<el-form-item label="博文内容">
83-
<mavon-editor ref=md v-model="article.content" @imgAdd="imgAdd" ></mavon-editor>
83+
<mavon-editor ref=md v-model="article.content" @imgAdd="imgAdd" @change="mavonChangeHandle"></mavon-editor>
8484
</el-form-item>
8585
<el-form-item>
8686
<el-button type="primary" @click="saveArticle()">保存</el-button>
@@ -247,6 +247,9 @@ export default {
247247
}).then(({data}) => {
248248
this.$refs.md.$img2Url(pos, data.resource.url)
249249
})
250+
},
251+
mavonChangeHandle (context, render) {
252+
this.article.contentFormat = render
250253
}
251254
}
252255
}

0 commit comments

Comments
 (0)