clean unmatched summary layout

This commit is contained in:
2026-05-08 22:56:37 +08:00
parent 1b8cbf92c7
commit 9fe218eb8e
3 changed files with 62 additions and 20 deletions

View File

@@ -222,12 +222,15 @@ def _render_sheet(sheet) -> str:
table = '<div class="empty">\u6b64\u5de5\u4f5c\u8868\u6ca1\u6709\u53ef\u9884\u89c8\u7684\u6570\u636e\u3002</div>'
if preview:
max_cols = min(max((len(row) for row in preview), default=0), 18)
unmatched_start = None
if preview and UNMATCHED in preview[0]:
unmatched_start = preview[0].index(UNMATCHED)
rows = []
for index, row in enumerate(preview):
cells = []
for value in (row + [""] * max_cols)[:max_cols]:
for col_index, value in enumerate((row + [""] * max_cols)[:max_cols]):
tag = "th" if index == 0 else "td"
css_class = ' class="extra-col"' if index == 0 and value == UNMATCHED else ""
css_class = ' class="extra-col"' if unmatched_start is not None and col_index >= unmatched_start else ""
cells.append(f"<{tag}{css_class}>{html.escape(value)}</{tag}>")
rows.append("<tr>" + "".join(cells) + "</tr>")
table = f'<div class="table-wrap"><table>{"".join(rows)}</table></div>'
@@ -460,7 +463,7 @@ def _page_shell(body: str, subtitle: str = "\u4e0a\u4f20\u201c\u5f85\u5904\u7406
white-space: nowrap;
}}
th {{ background: #fbfcfd; font-weight: 700; }}
th.extra-col {{ background: var(--extra); }}
th.extra-col, td.extra-col {{ background: var(--extra); }}
.empty {{
color: var(--muted);
font-size: 13px;