mirror of https://github.com/halo-dev/halo
🐛 修复更新文章后,文章摘要丢失的问题
parent
e30b01f858
commit
bd43112a3e
|
@ -227,7 +227,7 @@ public class AdminController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
* 不可描述的页面
|
||||
* Halo关于页面
|
||||
*
|
||||
* @return 模板路径admin/admin_halo
|
||||
*/
|
||||
|
|
|
@ -239,6 +239,19 @@ public class PostController extends BaseController {
|
|||
if (null == post.getPostDate()) {
|
||||
post.setPostDate(new Date());
|
||||
}
|
||||
//摘要字数
|
||||
int postSummary = 50;
|
||||
if (StrUtil.isNotEmpty(HaloConst.OPTIONS.get(BlogPropertiesEnum.POST_SUMMARY.getProp()))) {
|
||||
postSummary = Integer.parseInt(HaloConst.OPTIONS.get(BlogPropertiesEnum.POST_SUMMARY.getProp()));
|
||||
}
|
||||
//设置文章摘要
|
||||
String summaryText = StrUtil.cleanBlank(HtmlUtil.cleanHtmlTag(post.getPostContent()));
|
||||
if (summaryText.length() > postSummary) {
|
||||
String summary = summaryText.substring(0, postSummary);
|
||||
post.setPostSummary(summary);
|
||||
} else {
|
||||
post.setPostSummary(summaryText);
|
||||
}
|
||||
post = postService.buildCategoriesAndTags(post, cateList, tagList);
|
||||
post = postService.save(post);
|
||||
if (null != post) {
|
||||
|
|
Loading…
Reference in New Issue