From d48048d306535da00de4fd73943b1a88c6fa6964 Mon Sep 17 00:00:00 2001 From: xiaozzzi <42293085+xiaozzzi@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:13:13 +0800 Subject: [PATCH] =?UTF-8?q?pref:=20=E4=BC=98=E5=8C=96=E4=B8=B4=E6=97=B6?= =?UTF-8?q?=E8=AE=BF=E9=97=AE=E4=B8=AD=E7=9A=84=E7=9B=AE=E5=BD=95=E6=A0=B7?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/server/utils/ArticleUtil.java | 71 ++++++++++++------- .../src/main/resources/exportTemplate.html | 5 +- 2 files changed, 49 insertions(+), 27 deletions(-) diff --git a/blossom-backend/backend/src/main/java/com/blossom/backend/server/utils/ArticleUtil.java b/blossom-backend/backend/src/main/java/com/blossom/backend/server/utils/ArticleUtil.java index 878a70c..6563566 100644 --- a/blossom-backend/backend/src/main/java/com/blossom/backend/server/utils/ArticleUtil.java +++ b/blossom-backend/backend/src/main/java/com/blossom/backend/server/utils/ArticleUtil.java @@ -103,7 +103,7 @@ public class ArticleUtil { /** * */ - private static final String HEAD_SCRIPT_BLOG_COLOR = " " + - ""; + " \n"; - private static final String HEAD_SCRIPT_WATERMARK = ""; + " \n"; - private static final String BODY_HEADER_AND_TOC = "\n" + - "
\n" + - "
本文作者:{BLOSSOM_EXPORT_HTML_AUTHOR}。著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
\n" + + "
\n" + + "
本文作者:{BLOSSOM_EXPORT_HTML_AUTHOR}。著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
Export by Blossom\n" + - " \n" + - "\n" + - "
\n" + + " \n" + + "
\n" + + "
\n" + + "
\n" + + "
"; + + private static final String BODY_CONTENT_TOC = "\n" + "
\n" + "
《{BLOSSOM_EXPORT_HTML_ARTICLE_NAME}》
\n" + "
目录
\n" + - "
"; + "
\n"; - private static final String suffix = "
"; + private static final String suffix = "
"; private static String htmlTemplate; @@ -381,14 +386,10 @@ public class ArticleUtil { String WEB_BLOG_WATERMARK_COLOR, String WEB_BLOG_WATERMARK_GAP) { return htmlTemplate - + appendHeadScript(blogColor, - WEB_BLOG_WATERMARK_ENABLED, - WEB_BLOG_WATERMARK_CONTENT, - WEB_BLOG_WATERMARK_FONTSIZE, - WEB_BLOG_WATERMARK_COLOR, - WEB_BLOG_WATERMARK_GAP) - + appendBodyHeader(article, user) - + article.getHtml() + + appendHeadScript(blogColor, WEB_BLOG_WATERMARK_ENABLED, WEB_BLOG_WATERMARK_CONTENT, WEB_BLOG_WATERMARK_FONTSIZE, WEB_BLOG_WATERMARK_COLOR, WEB_BLOG_WATERMARK_GAP) + + appendBodyHeader(user) + + appendArticleContent(article) + + appendToc(article) + suffix; } @@ -421,15 +422,35 @@ public class ArticleUtil { } /** - * 增加页面顶部的文章作者和目录顶部的文章名称 + * 添加页面顶部的文章作者和目录顶部的文章名称 * * @param article 文章 * @param user 用户, 用户获取作者 * @return 页面顶部的文章作者和文章名称 */ - private static String appendBodyHeader(ArticleEntity article, UserEntity user) { - return BODY_HEADER_AND_TOC - .replaceAll("\\{BLOSSOM_EXPORT_HTML_AUTHOR}", user.getNickName()) + private static String appendBodyHeader(UserEntity user) { + return BODY_HEADER + .replaceAll("\\{BLOSSOM_EXPORT_HTML_AUTHOR}", user.getNickName()); + } + + /** + * 添加正文 + * + * @param article 文章 + */ + private static String appendArticleContent(ArticleEntity article) { + return article.getHtml() + + "\n
" + + "\n "; + } + + /** + * 添加目录 + * + * @param article 文章 + */ + private static String appendToc(ArticleEntity article) { + return BODY_CONTENT_TOC .replaceAll("\\{BLOSSOM_EXPORT_HTML_ARTICLE_NAME}", article.getName()); } } diff --git a/blossom-backend/backend/src/main/resources/exportTemplate.html b/blossom-backend/backend/src/main/resources/exportTemplate.html index 0bee0fe..e4f47ea 100644 --- a/blossom-backend/backend/src/main/resources/exportTemplate.html +++ b/blossom-backend/backend/src/main/resources/exportTemplate.html @@ -1398,8 +1398,9 @@ .toc { height: 100%; width: 300px; - padding-left: 15px; - border-right: 1px solid #eeeeee; + padding-left: 10px; + padding-bottom: 10px; + border-left: 1px solid #eeeeee; overflow-x: hidden; overflow-y: scroll; margin-top: 30px;