|
|
@@ -22,10 +22,26 @@ function renderStructuredData(items, type) {
|
|
|
|
|
|
// Render apply_to or apply_to_draft
|
|
|
const applyTo = item.apply_to_draft || item.apply_to;
|
|
|
+ const suggestApplyTo = item.apply_to_draft ? null : item.suggest_apply_to;
|
|
|
if (applyTo && typeof applyTo === 'object' && Object.keys(applyTo).length > 0) {
|
|
|
html += `<div class="structured-row">
|
|
|
<div class="structured-label">apply_to</div>
|
|
|
<div class="structured-value" style="display:flex; flex-direction:column; gap:6px;">`;
|
|
|
+
|
|
|
+ const renderPathBadge = (path, highlight = false) => {
|
|
|
+ const pathStr = typeof path === 'object' && path !== null
|
|
|
+ ? (path.element || path.category_path || path.path || '')
|
|
|
+ : String(path || '');
|
|
|
+ if (!pathStr) return '';
|
|
|
+ const parts = pathStr.split('/');
|
|
|
+ const leaf = parts.pop();
|
|
|
+ const prefix = parts.length > 0 ? parts.join('/') + '/' : '';
|
|
|
+ const leafStyle = highlight ? 'background:#eff6ff; color:#2563eb; border:1px solid #bfdbfe;' : '';
|
|
|
+ return `<span class="apply-to-path-item" ${highlight ? 'style="border: 2px dashed #94a3b8; background: transparent;"' : ''}>
|
|
|
+ ${prefix ? `<span class="apply-to-path-prefix">${prefix}</span>` : ''}
|
|
|
+ <span class="apply-to-path-leaf" style="${leafStyle}">${leaf}</span>
|
|
|
+ </span>`;
|
|
|
+ };
|
|
|
|
|
|
Object.entries(applyTo).forEach(([k, v]) => {
|
|
|
if (Array.isArray(v) && v.length > 0) {
|
|
|
@@ -33,18 +49,17 @@ function renderStructuredData(items, type) {
|
|
|
<span class="apply-to-key-badge">${k}</span>
|
|
|
<div class="apply-to-values">`;
|
|
|
v.forEach(path => {
|
|
|
- // split path to style the leaf node
|
|
|
- const parts = path.split('/');
|
|
|
- const leaf = parts.pop();
|
|
|
- const prefix = parts.length > 0 ? parts.join('/') + '/' : '';
|
|
|
- html += `<span class="apply-to-path-item">
|
|
|
- ${prefix ? `<span class="apply-to-path-prefix">${prefix}</span>` : ''}
|
|
|
- <span class="apply-to-path-leaf">${leaf}</span>
|
|
|
- </span>`;
|
|
|
+ html += renderPathBadge(path);
|
|
|
});
|
|
|
html += `</div></div>`;
|
|
|
}
|
|
|
});
|
|
|
+ if (typeof suggestApplyTo === 'string' && suggestApplyTo.trim()) {
|
|
|
+ html += `<div class="apply-to-subrow">
|
|
|
+ <span class="apply-to-key-badge">最优</span>
|
|
|
+ <div class="apply-to-values">${renderPathBadge(suggestApplyTo, true)}</div>
|
|
|
+ </div>`;
|
|
|
+ }
|
|
|
html += `</div></div>`;
|
|
|
}
|
|
|
|