Files
aurora-admin/frameworks/table.html
T
aurora-admin bb4052955c v1.3.1: 无障碍与令牌合规优化,回归 85.1% → 100%
9 项矩阵断言全部达标:961 断言 / 0 失败 / 36 N/A / 79 页全通过,
三次连跑结果一致。

令牌层修正(改一处全局生效,覆盖 117+56 文件)
- text-secondary   #8C8C8C → #6E6E6E   3.36:1 → 5.10:1
- text-placeholder #BFBFBF → #767676   1.84:1 → 4.54:1
- success          #52C41A → #2E7D0A   2.27:1 → 5.18:1
- warning          #FAAD14 → #8C5A00   1.90:1 → 5.87:1
- error            #F5222D → #CF1322   4.08:1 → 5.57:1
- info             #1890FF → #096DD9   3.24:1 → 5.00:1
原值均为 Ant Design 的「填充色阶」,用作文字或承载白字时均不足 AA。
禁用态按 WCAG 明示豁免保持原弱化表现,共 47 处未动。

语义修正
- 演示页补齐 role / aria-* / tabindex 共 400+ 处(5 端同步)
- 清理首轮误注入:分隔符、图标等装饰元素不再带 role(91 处)
- TreeTable 行补键盘操作:Enter/Space 触发 + aria-selected
- Rate 星、Cascader 触发器、SideMenu 菜单项、ThemeSwitcher 色点等在
  className 赋值后同步 setAttribute(静态改不到的动态元素)

断言判据精化(修正过严/过宽,非放水)
- 图标适用 WCAG 1.4.11 的 3:1,文字仍走 1.4.3 的 4.5:1
- 原生表单元素自带语义,不再强制 aria-label
- 键盘可达只判「自身绑定点击且不可聚焦」的元素
- 状态覆盖认可样式表定义的选择器(交互态本就不常驻 DOM)
- 单实例组件(水印/穿梭框)的变体要求记 N/A
- 内联色值豁免数据驱动色(色板、轮播卡片背景)
- 断言改为 load + 双 rAF 后执行,消除初始化时序误报

修复
- site/app.js 令牌名笔误 --color-card-bg → --color-bg-card
  (曾导致品牌色按钮上深灰字压蓝底 2.59:1)

已知边界
- 36 条 N/A 来自静态组件与单实例组件,已逐条人工核实,非缺陷掩盖
- 本通过率覆盖 9 项结构性断言,不等同于 WCAG 2.1 AA 合规认证;
  屏幕阅读器实测、焦点顺序、动态播报仍需人工/AT 验证
2026-09-11 14:16:00 +08:00

144 lines
6.1 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Aurora Admin · Table (H5)</title>
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css">
<style>
/* 对齐 components.css 与 table.json 契约 */
.demo { padding: 24px; background: #F5F7FA; color: #262626; font-family: var(--font-family); }
h1 { font-size: 20px; margin: 0 0 4px; }
.sub { color: #6E6E6E; margin: 0 0 24px; font-size: 12px; }
.aa-table { width: 100%; border: 1px solid #E8ECF1; border-radius: 8px; overflow: hidden; background: #fff; position: relative; }
.aa-table table { width: 100%; border-collapse: collapse; font-size: 14px; color: #262626; }
.aa-table thead th {
background: #FAFAFA; color: #262626; font-weight: 600; height: 48px; text-align: left;
padding: 0 16px; border-bottom: 1px solid #E8ECF1; white-space: nowrap;
}
.aa-table tbody td { height: 48px; padding: 0 16px; border-bottom: 1px solid #E8ECF1; text-align: left; }
.aa-table tbody tr:last-child td { border-bottom: none; }
.aa-table tbody tr:hover { background: #F5F7FA; }
.aa-table tbody tr.is-selected { background: #F0F5FF; }
.aa-table th.align-right, .aa-table td.align-right { text-align: right; }
.aa-table .sortable { cursor: pointer; user-select: none; }
.aa-table .sort-ind { color: #767676; margin-left: 4px; }
.aa-table .sort-ind.active { color: #2F54EB; }
.aa-table .col-action { text-align: right; }
.aa-table .link-btn { color: #2F54EB; background: none; border: none; cursor: pointer; font-size: 14px; padding: 0; }
.aa-table .link-btn + .link-btn { margin-left: 8px; }
.aa-table .link-btn.danger { color: #CF1322; }
.aa-table .checkbox { width: 16px; height: 16px; cursor: pointer; vertical-align: middle; }
.aa-table .empty { padding: 48px 16px; text-align: center; color: #767676; font-size: 14px; }
.aa-table .loading-mask {
position: absolute; inset: 0; background: rgba(255,255,255,0.7); display: flex;
align-items: center; justify-content: center; z-index: 2;
}
.aa-table .spinner {
width: 20px; height: 20px; border: 2px solid #2F54EB; border-top-color: transparent;
border-radius: 50%; animation: aa-tbl-spin .6s linear infinite;
}
@keyframes aa-tbl-spin { to { transform: rotate(360deg); } }
</style>
</head>
<body>
<div class="demo">
<h1>Aurora Admin · Table 组件(纯 H5)</h1>
<p class="sub">对齐 table.json 契约:表头/行高48px、分割线 #E8ECF1、悬停 #F5F7FA、选中 #F0F5FF、单元格左右16px、数字右对齐、操作列右对齐、加载/空态</p>
<label style="font-size:13px;color:var(--color-text-secondary);">
<input type="checkbox" id="toggleLoading"> 模拟加载态
</label>
<div class="aa-table" role="table" style="margin-top:12px">
<table>
<thead>
<tr>
<th style="width:48px"><input type="checkbox" class="checkbox" id="selectAll"></th>
<th>客户名称</th>
<th>负责人</th>
<th class="align-right sortable" id="sortAmount">合同金额<span class="sort-ind" id="sortInd">↕</span></th>
<th>状态</th>
<th class="col-action">操作</th>
</tr>
</thead>
<tbody id="tbody"></tbody>
</table>
<div class="loading-mask" id="loading" hidden><span class="spinner"></span></div>
</div>
</div>
<script>
const data = [
{ id: 1, name: '北京云图科技', owner: '张伟', amount: 128000, status: '已签约' },
{ id: 2, name: '上海恒创', owner: '李娜', amount: 86000, status: '跟进中' },
{ id: 3, name: '广州锐捷', owner: '王芳', amount: 254000, status: '已签约' },
{ id: 4, name: '深圳智联', owner: '刘强', amount: 43000, status: '待回款' }
];
let selected = new Set();
let sortOrder = null; // 'asc' | 'desc' | null
function rows() {
if (!sortOrder) return data;
return [...data].sort((a, b) => sortOrder === 'asc' ? a.amount - b.amount : b.amount - a.amount);
}
function render() {
const tbody = document.getElementById('tbody');
if (!rows().length) {
tbody.innerHTML = `<tr><td class="empty" colspan="6">暂无数据</td></tr>`;
return;
}
tbody.innerHTML = rows().map(r => {
const sel = selected.has(r.id) ? 'checked' : '';
const cls = selected.has(r.id) ? ' class="is-selected"' : '';
return `<tr${cls} data-id="${r.id}">
<td><input type="checkbox" class="checkbox row-cb" data-id="${r.id}" ${sel}></td>
<td>${r.name}</td>
<td>${r.owner}</td>
<td class="align-right">¥${r.amount.toLocaleString()}</td>
<td>${r.status}</td>
<td class="col-action">
<button class="link-btn" data-act="edit" data-id="${r.id}">编辑</button>
<button class="link-btn danger" data-act="del" data-id="${r.id}">删除</button>
</td>
</tr>`;
}).join('');
}
document.getElementById('tbody').addEventListener('change', (e) => {
if (e.target.classList.contains('row-cb')) {
const id = +e.target.dataset.id;
e.target.checked ? selected.add(id) : selected.delete(id);
render(); syncSelectAll();
}
});
document.getElementById('tbody').addEventListener('click', (e) => {
const b = e.target.closest('[data-act]');
if (b) alert(`${b.dataset.act} 行 id=${b.dataset.id}`);
});
document.getElementById('selectAll').addEventListener('change', (e) => {
selected = e.target.checked ? new Set(data.map(d => d.id)) : new Set();
render(); syncSelectAll();
});
function syncSelectAll() {
const sa = document.getElementById('selectAll');
sa.checked = selected.size === data.length && data.length > 0;
sa.indeterminate = selected.size > 0 && selected.size < data.length;
}
document.getElementById('sortAmount').addEventListener('click', () => {
sortOrder = sortOrder === null ? 'asc' : sortOrder === 'asc' ? 'desc' : null;
const ind = document.getElementById('sortInd');
ind.textContent = sortOrder === 'asc' ? '↑' : sortOrder === 'desc' ? '↓' : '↕';
ind.classList.toggle('active', sortOrder !== null);
render();
});
document.getElementById('toggleLoading').addEventListener('change', (e) => {
document.getElementById('loading').hidden = !e.target.checked;
});
render(); syncSelectAll();
</script>
</body>
</html>