F2-17 UI: format=amis 剥 page 壳——弹窗只渲表单本体,消三层标题嵌套
format=amis 仅弹窗 service 路径使用;根 type:page 且 body 为单对象时只下发 body,page.title/留白不再叠进 dialog(D4 弹窗嵌整页的运行时修复)。其余形态 (根非 page/body 数组/解析失败)原样下发不冒险拆。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -232,7 +232,9 @@ public class PageSchemaController {
|
||||
}
|
||||
|
||||
String schemaJson = String.valueOf(row.get("schema_json"));
|
||||
String body = amisEnvelope ? "{\"status\":0,\"msg\":\"\",\"data\":" + schemaJson + "}" : schemaJson;
|
||||
String body = amisEnvelope
|
||||
? "{\"status\":0,\"msg\":\"\",\"data\":" + unwrapPageChrome(schemaJson) + "}"
|
||||
: schemaJson;
|
||||
ResponseEntity.BodyBuilder builder = ResponseEntity.ok()
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header(HEADER_SCHEMA_LAYER, layer);
|
||||
@@ -242,6 +244,28 @@ public class PageSchemaController {
|
||||
return builder.body(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* F2-17 UI:弹窗嵌整页剥壳。{@code format=amis} 仅弹窗 service 路径使用(主渲染器取裸
|
||||
* schema),此时去掉 page 包装(page.title 会与 dialog 标题、form 面板叠成多层标题 +
|
||||
* 整页留白)。根节点是 {@code type:page} 且 body 为单个对象时返回 body,其余形态原样返回
|
||||
* (body 为数组/缺失、解析失败都不冒险拆)。
|
||||
*/
|
||||
static String unwrapPageChrome(String schemaJson) {
|
||||
try {
|
||||
com.fasterxml.jackson.databind.JsonNode root = SCHEMA_MAPPER.readTree(schemaJson);
|
||||
if (root != null && root.isObject() && "page".equals(root.path("type").asText())
|
||||
&& root.path("body").isObject()) {
|
||||
return SCHEMA_MAPPER.writeValueAsString(root.get("body"));
|
||||
}
|
||||
} catch (com.fasterxml.jackson.core.JacksonException ex) {
|
||||
log.warn("[F2-17] schema 剥 page 壳失败,按原样下发: {}", ex.getMessage());
|
||||
}
|
||||
return schemaJson;
|
||||
}
|
||||
|
||||
private static final com.fasterxml.jackson.databind.ObjectMapper SCHEMA_MAPPER =
|
||||
new com.fasterxml.jackson.databind.ObjectMapper();
|
||||
|
||||
/** If-None-Match 可为逗号分隔多值或 {@code *};任一匹配即命中。 */
|
||||
private boolean etagMatches(String ifNoneMatch, String etag) {
|
||||
String header = ifNoneMatch.trim();
|
||||
|
||||
Reference in New Issue
Block a user