feat: 效果修改
All checks were successful
缓存序列化结构检查 / cache-schema-check (push) Has been skipped

This commit is contained in:
2026-07-14 11:38:18 +08:00
parent 4da632bd5c
commit a6fdc5fc5e
3 changed files with 50 additions and 88 deletions

View File

@@ -57,9 +57,9 @@ public class ReportBuilder {
Set<String> oldHighlight = SkeletonAnnotator.pathsForOldSkeleton(kc.getFieldDetails());
Set<String> newHighlight = SkeletonAnnotator.pathsForNewSkeleton(kc.getFieldDetails());
String oldRendered = oldJson.isEmpty()
? "" : SkeletonAnnotator.annotateAsCodeBlock(oldJson, oldHighlight);
? "" : "" + SkeletonAnnotator.annotateForWecom(oldJson, oldHighlight) + "";
String newRendered = newJson.isEmpty()
? "" : SkeletonAnnotator.annotateAsCodeBlock(newJson, newHighlight);
? "" : "" + SkeletonAnnotator.annotateForWecom(newJson, newHighlight) + "";
if (oldJson.isEmpty() && !newJson.isEmpty()) {
sb.append(" value 新增为 ").append(newRendered).append("\n\n");
} else if (!oldJson.isEmpty() && newJson.isEmpty()) {
@@ -73,13 +73,14 @@ public class ReportBuilder {
}
/**
* Key 行:Key --> + 橙红色 key企微 warning
* 末尾加零宽空格,避免 key 中的 * 干扰后续 markdown
* Key 行:warning 颜色 + 行内代码 + 加粗
* 企微支持混用;代码样式可能略压过加粗,但颜色与代码块会稳定生效
* key 包在反引号内,避免路径中的 {@code *} 干扰 markdown。
*/
private void appendKeyLine(StringBuilder sb, String keyPattern) {
sb.append("- Key --> <font color=\"warning\">")
sb.append("- Key --> <font color=\"warning\">**`")
.append(nvl(keyPattern))
.append("\u200b</font>\n");
.append("`**</font>\n");
}
/**

View File

@@ -10,7 +10,7 @@ import java.util.List;
import java.util.Set;
/**
* 在骨架 JSON 中为改动字段加企微 warning 标注。
* 在骨架 JSON 中为改动字段加企微 warning 标注(仅改动片段染色,其余明文)
* <ul>
* <li>删除字段 → 标在旧骨架</li>
* <li>新增字段 / 新增包装层 → 标在新骨架</li>
@@ -66,15 +66,19 @@ final class SkeletonAnnotator {
}
/**
* 标注路径对应的 {@code "field":value} 片段,并包成可与代码块混排的企微 Markdown
* 企微代码块内不解析 font故整段用反引号分段包裹改动项单独用 warning+反引号。
* 标注改动字段:其余正文保持普通文本(避免整段包反引号导致企微整段变红)
* 改动片段格式:{@code <font color="warning">"field":value</font>}
*/
static String annotateAsCodeBlock(String json, Set<String> highlightPaths) {
static String annotateForWecom(String json, Set<String> highlightPaths) {
if (json == null || json.isEmpty()) {
return "``";
return "";
}
String annotated = annotate(json, highlightPaths);
return toMixedCodeMarkdown(annotated);
return annotate(json, highlightPaths);
}
/** @deprecated 使用 {@link #annotateForWecom},勿再整段包代码块 */
static String annotateAsCodeBlock(String json, Set<String> highlightPaths) {
return annotateForWecom(json, highlightPaths);
}
static String annotate(String json, Set<String> highlightPaths) {
@@ -90,57 +94,6 @@ final class SkeletonAnnotator {
return result;
}
/**
* 将已含 {@code <font>} 的字符串拆成:普通段走反引号代码块,改动段走 warning+反引号。
*/
static String toMixedCodeMarkdown(String annotated) {
if (annotated == null || annotated.isEmpty()) {
return "``";
}
if (!annotated.contains(FONT_OPEN)) {
return "`" + annotated + "`";
}
StringBuilder out = new StringBuilder();
int i = 0;
boolean inCode = false;
while (i < annotated.length()) {
int start = annotated.indexOf(FONT_OPEN, i);
if (start < 0) {
if (!inCode) {
out.append('`');
inCode = true;
}
out.append(annotated.substring(i));
out.append('`');
return out.toString();
}
if (start > i) {
if (!inCode) {
out.append('`');
inCode = true;
}
out.append(annotated, i, start);
out.append('`');
inCode = false;
} else if (inCode) {
out.append('`');
inCode = false;
}
int contentStart = start + FONT_OPEN.length();
int end = annotated.indexOf(FONT_CLOSE, contentStart);
if (end < 0) {
if (!inCode) {
out.append('`');
}
out.append(annotated.substring(start)).append('`');
return out.toString();
}
String frag = annotated.substring(contentStart, end);
out.append(FONT_OPEN).append('`').append(frag).append('`').append(FONT_CLOSE);
i = end + FONT_CLOSE.length();
}
return out.toString();
}
private static void addIfPresent(Set<String> paths, String path) {
if (path != null && !path.trim().isEmpty()) {