Aurora Admin v1.2.0: 79 components x 5 ends, doc site, contracts batch 1, playground, regression, deploy ready

This commit is contained in:
aurora-admin
2026-09-10 19:21:56 +08:00
commit 51ce3a28f7
654 changed files with 49082 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
<!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 · Rate (H5)</title>
<link rel="stylesheet" href="../.design_library/aurora-admin/colors_and_type.css">
<link rel="stylesheet" href="./Rate.css">
<style>
.demo { padding: 24px; background: #F5F7FA; font-family: var(--font-family); }
h1 { font-size: 20px; margin: 0 0 4px; color: #1F2329; }
.sub { color: #8C8C8C; margin: 0 0 24px; font-size: 12px; }
.demo-block { background: #fff; border-radius: 8px; padding: 16px; margin-bottom: 20px; }
.demo-block > .hint { color: #8C8C8C; font-size: 12px; margin: 0 0 12px; }
</style>
</head>
<body>
<div class="demo">
<h1>Aurora Admin · Rate 组件(纯 H5)</h1>
<p class="sub">对齐 RateInput 规范:星级、半星、只读、尺寸、文字</p>
<div class="demo-block">
<p class="hint">基础(点击评分)</p>
<div class="aa-rate" data-rate data-count="5" data-value="3"></div>
</div>
<div class="demo-block">
<p class="hint">允许半星</p>
<div class="aa-rate" data-rate data-count="5" data-value="2.5" data-half></div>
</div>
<div class="demo-block">
<p class="hint">只读 + 显示文字</p>
<div class="aa-rate is-readonly" data-rate data-count="5" data-value="4" data-text></div>
</div>
<div class="demo-block">
<p class="hint">尺寸:small / default / large</p>
<div class="aa-rate sm" data-rate data-count="5" data-value="3"></div>
<div class="aa-rate" data-rate data-count="5" data-value="3"></div>
<div class="aa-rate lg" data-rate data-count="5" data-value="3"></div>
</div>
</div>
<script>
function renderRate(root) {
const count = +root.dataset.count || 5;
const allowHalf = root.hasAttribute('data-half');
const showText = root.hasAttribute('data-text');
const texts = ['极差', '失望', '一般', '满意', '惊喜'];
let value = parseFloat(root.dataset.value) || 0;
function paint() {
root.innerHTML = '';
for (let i = 0; i < count; i++) {
const ratio = Math.max(0, Math.min(1, value - i));
const star = document.createElement('span');
star.className = 'aa-rate-star';
star.dataset.index = i;
star.innerHTML = '★<span class="aa-rate-fill" style="width:' + (ratio * 100) + '%">★</span>';
root.appendChild(star);
}
if (showText) {
const t = document.createElement('span');
t.className = 'aa-rate-text';
t.textContent = value ? texts[Math.ceil(value) - 1] : '未评分';
root.appendChild(t);
}
}
root.addEventListener('click', (e) => {
if (root.classList.contains('is-readonly') || root.classList.contains('is-disabled')) return;
const star = e.target.closest('.aa-rate-star');
if (!star) return;
const i = +star.dataset.index;
let next;
if (allowHalf) {
const rect = star.getBoundingClientRect();
const half = (e.clientX - rect.left) < rect.width / 2;
next = half ? i + 0.5 : i + 1;
} else {
next = i + 1;
}
if (next === value) next = 0; // 再次点击同一星清零
value = next;
root.dataset.value = value;
paint();
});
paint();
}
document.querySelectorAll('[data-rate]').forEach(renderRate);
</script>
</body>
</html>