diff --git a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java index 4a604f47a5..60cc13b2d9 100644 --- a/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/AbstractIssuePlatform.java @@ -41,6 +41,8 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; public abstract class AbstractIssuePlatform implements IssuesPlatform { @@ -222,10 +224,48 @@ public abstract class AbstractIssuePlatform implements IssuesPlatform { document.select("br").append("\\n"); document.select("p").prepend("\\n\\n"); String s = document.html().replaceAll("\\\\n", "\n"); - String desc = Jsoup.clean(s, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)); + String desc = htmlImg2MsImg(s); + desc = Jsoup.clean(desc, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false)); return desc.replace(" ", ""); } + protected String msImg2HtmlImg(String input, String endpoint) { + // ![中心主题.png](/resource/md/get/a0b19136_中心主题.png) -> + String regex = "(\\!\\[.*?\\]\\((.*?)\\))"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(input); + String result = ""; + while (matcher.find()) { + String path = matcher.group(2); + if (endpoint.endsWith("/")) { + endpoint = endpoint.substring(0, endpoint.length() -1); + } + path = " "; + result = matcher.replaceFirst(path); + matcher = pattern.matcher(result); + } + return result; + } + + protected String htmlImg2MsImg(String input) { + // -> ![中心主题.png](/resource/md/get/a0b19136_中心主题.png) + String regex = "()"; + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(input); + String result = input; + while (matcher.find()) { + String url = matcher.group(2); + if (url.contains("/resource/md/get/")) { + String path = url.substring(url.indexOf("/resource/md/get/")); + String name = path.substring(path.lastIndexOf("/") + 10); + String mdLink = "![" + name + "](" + path + ")"; + result = matcher.replaceFirst(mdLink); + matcher = pattern.matcher(result); + } + } + return result; + } + protected UserDTO.PlatformInfo getUserPlatInfo(String orgId) { return userService.getCurrentPlatformInfo(orgId); } diff --git a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java index 9001607993..8dda12e7c9 100644 --- a/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java +++ b/backend/src/main/java/io/metersphere/track/issue/TapdPlatform.java @@ -11,11 +11,13 @@ import io.metersphere.commons.constants.IssuesManagePlatform; import io.metersphere.commons.constants.IssuesStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.BeanUtils; +import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.LogUtil; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.ResultHolder; import io.metersphere.dto.CustomFieldItemDTO; import io.metersphere.dto.UserDTO; +import io.metersphere.service.SystemParameterService; import io.metersphere.track.dto.DemandDTO; import io.metersphere.track.issue.client.TapdClient; import io.metersphere.track.issue.domain.PlatformUser; @@ -140,6 +142,8 @@ public class TapdPlatform extends AbstractIssuePlatform { } private String msDescription2Tapd(String msDescription) { + SystemParameterService parameterService = CommonBeanFactory.getBean(SystemParameterService.class); + msDescription = msImg2HtmlImg(msDescription, parameterService.getValue("base.url")); return msDescription.replaceAll("\\n", "
"); } diff --git a/frontend/src/business/components/track/case/components/FormRichTextItem.vue b/frontend/src/business/components/track/case/components/FormRichTextItem.vue index bad7c71076..8286b315a1 100644 --- a/frontend/src/business/components/track/case/components/FormRichTextItem.vue +++ b/frontend/src/business/components/track/case/components/FormRichTextItem.vue @@ -1,7 +1,7 @@ diff --git a/frontend/src/business/components/track/issue/IssueDescriptionTableItem.vue b/frontend/src/business/components/track/issue/IssueDescriptionTableItem.vue index 71a9ad4e4c..2f1146e695 100644 --- a/frontend/src/business/components/track/issue/IssueDescriptionTableItem.vue +++ b/frontend/src/business/components/track/issue/IssueDescriptionTableItem.vue @@ -11,8 +11,8 @@ trigger="hover" popper-class="issues-popover" > - + {{ $t('test_track.issue.preview') }} @@ -20,15 +20,12 @@