From 64b9a61276d6cb4bfe1b44a6e2e8ff294d0f6266 Mon Sep 17 00:00:00 2001 From: xiaozzzi <42293085+xiaozzzi@users.noreply.github.com> Date: Wed, 17 Apr 2024 00:41:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=B4=E6=97=B6=E8=AE=BF=E9=97=AE?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B0=B4=E5=8D=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../article/draft/ArticleController.java | 16 +- .../backend/server/utils/ArticleUtil.java | 316 +++++++++++++++--- .../src/main/resources/exportTemplate.html | 16 +- 3 files changed, 295 insertions(+), 53 deletions(-) diff --git a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleController.java b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleController.java index 813b899..21c3d8d 100644 --- a/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleController.java +++ b/blossom-backend/backend/src/main/java/com/blossom/backend/server/article/draft/ArticleController.java @@ -265,7 +265,13 @@ public class ArticleController { } String reportHtml = ArticleUtil.toHtml(article, userService.selectById(AuthContext.getUserId()), - userParamService.getValue(AuthContext.getUserId(), UserParamEnum.WEB_BLOG_COLOR).getParamValue()); + userParamService.getValue(AuthContext.getUserId(), UserParamEnum.WEB_BLOG_COLOR).getParamValue(), + userParamService.getValue(AuthContext.getUserId(), UserParamEnum.WEB_BLOG_WATERMARK_ENABLED).getParamValue(), + userParamService.getValue(AuthContext.getUserId(), UserParamEnum.WEB_BLOG_WATERMARK_CONTENT).getParamValue(), + userParamService.getValue(AuthContext.getUserId(), UserParamEnum.WEB_BLOG_WATERMARK_FONTSIZE).getParamValue(), + userParamService.getValue(AuthContext.getUserId(), UserParamEnum.WEB_BLOG_WATERMARK_COLOR).getParamValue(), + userParamService.getValue(AuthContext.getUserId(), UserParamEnum.WEB_BLOG_WATERMARK_GAP).getParamValue() + ); try (InputStream is = new ByteArrayInputStream(reportHtml.getBytes(StandardCharsets.UTF_8)); BufferedInputStream bis = new BufferedInputStream(is)) { String filename = URLEncodeUtil.encode(article.getName() + ".html"); @@ -339,6 +345,12 @@ public class ArticleController { return ArticleUtil.toHtml( article, userService.selectById(visit.getUserId()), - userParamService.getValue(visit.getUserId(), UserParamEnum.WEB_BLOG_COLOR).getParamValue()); + userParamService.getValue(visit.getUserId(), UserParamEnum.WEB_BLOG_COLOR).getParamValue(), + userParamService.getValue(visit.getUserId(), UserParamEnum.WEB_BLOG_WATERMARK_ENABLED).getParamValue(), + userParamService.getValue(visit.getUserId(), UserParamEnum.WEB_BLOG_WATERMARK_CONTENT).getParamValue(), + userParamService.getValue(visit.getUserId(), UserParamEnum.WEB_BLOG_WATERMARK_FONTSIZE).getParamValue(), + userParamService.getValue(visit.getUserId(), UserParamEnum.WEB_BLOG_WATERMARK_COLOR).getParamValue(), + userParamService.getValue(visit.getUserId(), UserParamEnum.WEB_BLOG_WATERMARK_GAP).getParamValue() + ); } } 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 dd6f39b..878a70c 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 @@ -1,18 +1,16 @@ package com.blossom.backend.server.utils; import cn.hutool.core.util.ArrayUtil; -import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import com.blossom.backend.base.user.pojo.UserEntity; import com.blossom.backend.server.article.draft.pojo.ArticleEntity; -import com.blossom.common.base.util.DateUtils; +import com.blossom.common.base.enums.YesNo; import lombok.extern.slf4j.Slf4j; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.Resource; import java.io.IOException; import java.io.InputStream; -import java.util.Date; /** * 文章工具类 @@ -105,7 +103,7 @@ public class ArticleUtil { /** * */ - private static final String SCRIPT_TAG_BLOG_COLOR = " " + ""; + private static final String HEAD_SCRIPT_WATERMARK = ""; - private static final String prefix = "\n" + + + private static final String BODY_HEADER_AND_TOC = "\n" + "