Files
aurora-admin/site/sources/select/css.txt
T
aurora-admin 16f365a045 feat: P4 阶段A+B — data.js 瘦身 116KB(预计算 + css 分离)
执行 ROADMAP 的 S1-P4,按规划的三阶段走,本次完成 A 与 B。

阶段 A · 预计算 scenarios(验证「构建期预计算 + 运行时回退」链路)
- tools/precompute.mjs:与 app.js 的 extractScenarios 逻辑完全一致,
  构建期算出结果写进 data.components[].scenarios
- app.js 加快速路径:优先读 c.scenarios,缺失时回退运行时解析
- 浏览器实测:预计算值与运行时提取值**完全一致**(逐字节比对)
- 实测收益有限:仅 4 个组件有 ≥2 场景(场景卡片本就少见),
  但链路验证通过,为阶段 C 的 API 预计算铺路

阶段 B · css 源码分离(零风险,css 不参与任何解析)
- css 从 data.js 移到 site/sources/<slug>/css.txt(79 个文件)
- data.js 里改为 sourcesRef.css 引用,data.json 保持完整(For Agents 承诺)
- data.js: 1058 KB → 942 KB(−116 KB)
- app.js 新增 srcOf(c, kind) / hasSrc(c, kind):
  · srcOf 同步返回已有源码,缺失时触发后台 fetch 并缓存
  · __aaSrcReady 回调在加载完成后填充代码区
- 修正回调时机 bug:原实现捕获构建时的 current(初始 tab),
  导致用户后续切换的 tab 收不到通知。改为回调内实时比对当前 tab

关于 P4 的实测修正(已登记 ROADMAP 规划修正记录)
- 规划估计「拆 sources → ~110KB」。实测 css 仅占 119KB/888KB,
  且 html/vue2/vue3/jsx 共 765KB 被**渲染期同步消费**
  (extractComponentAPI 读 vue3/vue2/jsx,extractScenarios 读 html)
- 故需分阶段:A+B 先减 116KB,阶段 C 需先预计算 API 表才能分离其余 4 端

新增构建链(两步,不可省第二步)
- npm run build:site = build-site.ps1 + precompute.mjs
- build-site.ps1 会把 data.js 重写回全量,precompute 才做瘦身
- 已写入 AGENTS.md 的铁律章节(含「只跑第一步会怎样」的后果说明)

验证
- 回归 100%:1003/1003,79 页全通过,N/A 35
- 浏览器实测:展开代码区 → CSS tab → 2121 字符正常显示,
  Network 出现 sources/button/css.txt 请求
- 预计算 vs 运行时场景提取结果逐字节一致
2026-09-11 23:23:08 +08:00

39 lines
2.9 KiB
Plaintext
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.
/* Aurora Admin Select 样式 — 对齐 components.css 与 select.json 契约(触发器同 Input) */
.aa-select { position: relative; display: inline-block; min-width: 220px; }
.aa-select-trigger {
display: flex; align-items: center; gap: 8px; min-height: 32px; height: auto;
padding: 2px 28px 2px 12px; background: var(--au-color-card-bg); border: 1px solid var(--au-color-border);
border-radius: 4px; box-sizing: border-box; cursor: pointer; transition: border-color .15s, box-shadow .15s;
font-size: 14px; color: var(--au-color-text-body); flex-wrap: wrap; position: relative;
}
.aa-select-trigger:hover { border-color: var(--au-color-brand); }
.aa-select.is-open .aa-select-trigger { border-color: var(--au-color-brand); box-shadow: 0 0 0 2px rgba(47,84,235,0.2); }
.aa-select.is-disabled .aa-select-trigger { background: var(--au-color-disabled-bg); border-color: transparent; color: var(--au-color-text-disabled); cursor: not-allowed; }
.aa-select-trigger .placeholder { color: var(--au-color-text-placeholder); }
.aa-select-trigger .caret { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); transition: transform .15s; color: var(--au-color-text-secondary); }
.aa-select.is-open .caret { transform: translateY(-50%) rotate(180deg); }
.aa-select-trigger .tag {
display: inline-flex; align-items: center; gap: 4px; background: var(--au-color-brand-bg); color: var(--au-color-brand);
border-radius: 2px; padding: 1px 6px; font-size: 12px; line-height: 20px;
}
.aa-select-trigger .tag .x { cursor: pointer; }
.aa-select-panel {
position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; right: 0;
background: var(--au-color-card-bg); border-radius: 4px; box-shadow: 0 4px 16px rgba(0,0,0,0.12);
max-height: 256px; overflow-y: auto; padding: 4px 0;
}
.aa-select-search { padding: 6px 8px; border-bottom: 1px solid var(--au-color-border-strong); }
.aa-select-search input { width: 100%; box-sizing: border-box; border: 1px solid var(--au-color-border); border-radius: 4px; padding: 4px 8px; font-size: 13px; outline: none; }
.aa-select-search input:focus { border-color: var(--au-color-brand); }
.aa-select-group-label { padding: 6px 12px; font-size: 12px; color: var(--au-color-text-secondary); }
.aa-select-option {
display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 32px; cursor: pointer;
font-size: 14px; color: var(--au-color-text-body); box-sizing: border-box;
}
.aa-select-option:hover { background: var(--au-color-page-bg); }
.aa-select-option.is-selected { background: var(--au-color-brand-bg); color: var(--au-color-brand); }
.aa-select-option .check { visibility: hidden; margin-left: auto; }
.aa-select-option.is-selected .check { visibility: visible; }
.aa-select-option.is-disabled { color: var(--au-color-text-disabled); cursor: not-allowed; }
.aa-select-empty { padding: 16px 12px; text-align: center; color: var(--au-color-text-placeholder); font-size: 13px; }