diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2c4545b..bbfc579 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -41,7 +41,7 @@ build esbuild 打包到 dist/(单 dist/app.js = src/ 模块按序 node --check app.js 与 dist/app.js 语法 check-dist.js 产物体检 lint ESLint(src/ + app.js,正确性规则) -test:unit 117 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底)) +test:unit 118 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底)) test relay-task-graph-fixture + iwb-v32-web-test test:facts 事实基线守门(见 §5) typecheck 渐进类型检查(tsc --noEmit;范围 = src/*.js,不含 app.js) diff --git a/docs/plans/design-tokens-rollout.md b/docs/plans/design-tokens-rollout.md index 8e4cc89..895edd2 100644 --- a/docs/plans/design-tokens-rollout.md +++ b/docs/plans/design-tokens-rollout.md @@ -30,7 +30,7 @@ |---|---|---|---|---| | **M0** | 决策 + 视觉基线 | 基线截图 + 4 个决定定稿 | 0.5d | ✅ 已完成 2026-11-23 | | **M1** | 清账 | 未定义变量清零、审计脚本入库 | 0.5d | ✅ 已完成 2026-11-23 | -| **M2** | 色彩模型重建(D1–D9) | 对比度全绿、单一写入点 | 1.5d | M1 | +| **M2** | 色彩模型重建(D1–D9) | 对比度全绿、单一写入点 | 1.5d | ✅ 已完成 2026-11-23 | | **M3** | 单一源 + 导出 | `design-tokens.css`、`tokens.json` | 1d | M2 | | **M4** | 六批迁移 | 尺度收敛、5 套 tab 合一 | 3.5d | M3 | | **M5** | 闸门与治理 | `token-lint`、棘轮测试、RFC | 1d | M4 | @@ -66,26 +66,30 @@ **回滚**:单 commit 可 revert。 -### M2 色彩模型重建(1.5d,**有可见变化**,独立版本发) +### M2 色彩模型重建(1.5d,**有可见变化**,独立版本发)—— ✅ 已完成 2026-11-23 这是整个计划里唯一「用户会发现界面变了」的阶段,所以单独发版、单独附对比图。 +逐条做法与实测数字见 `design-tokens.md` §1.8,这里只记**与计划的偏差**(计划是纸上的,执行会碰到真东西)。 -| ID | 缺陷 | 具体改法 | 验收 | +| ID | 缺陷 | 执行结果 | 与计划的偏差及理由 | |---|---|---|---| -| T2.1a | **D1③ 系统跟随不重算(已在 3.26.43 修完)** | `app.js` mq 回调派发 `iwb:theme-change`,`applyAppearance` 的 effect 订阅后重跑(行数零增长) | `iwb-canvas-ops` 的 ⑫-b 用例:class 变 + `--iwb-bg` 变暗 | ✅ | -| T2.1 | D1 三写入者(②③ 属本阶段) | ① `.theme-dark` 只保留 `--iwb-anim-*`、`--sh-*`、结构性尺寸(`--iwb-nav-w` 等),颜色值全部删(由 derive 统一写)② **JS 不再写 `chrome/dock/home/hr`**,改由 CSS `color-mix` 从 `--iwb-bg`/`--iwb-canvas-bg` 派生(消掉第二套公式)③ `app.js:3497` 的 mq 回调改为派发 `iwb-theme-change` 事件,React 侧 `setTheme` 重算 | 首帧与 apply 后**无跳变**(录屏逐帧看);系统切暗后 1 帧内变色 | -| T2.2 | D3 夹错表面 | `clampText(fg, bgList, min)`:对 `bg/panel/layer/nodeBg/pluginCard` 逐个校验取最严;**canvas 不参与**(见 T2.5) | `tests/theme-contrast-test.js` 全绿 | -| T2.3 | D4 text2 只保 3.2 | `text2` 提到 4.5;新增 `--iwb-color-text-tertiary`(3:1),规范限定「只许非正文:占位符、图标旁注、禁用态」 | 同上 + 静态扫描:tertiary 不得用于 `font-size ≥ 12px` 的正文容器(人工评审) | -| T2.4 | D5 textDim 不可读 | 系数从 0.35 调到落在 3:1(约 0.2),或直接并入 tertiary 后删除 | 实测 ≥3:1 | -| T2.5 | D4 节点标题在画布上 1.9:1 | 新增 `--iwb-color-text-on-canvas`(对 canvasBg ≥4.5),`.iwb-node-title` 改用它并去掉 `opacity:.8`;选中态用字重而非透明度区分 | 画布截图目视 + 对比度断言 | -| T2.6 | D6 layer 方向翻转 + **一词多义** | 把 `--iwb-layer` 按实际用途拆成 4 个语义:`bg-inset`(任务块/引用块/输入)、`bg-hover`(悬停)、`bg-menu`(右键菜单/确认框/ws-more)、`bg-chip`(chip/端口/小标签)。亮色一律「比 panel 暗」,暗色 `bg-inset` 比 panel 更暗、`bg-menu` 比 panel 亮 | 每类至少 3 个组件截图对比;`grep -c 'var(--iwb-layer)'` 从 59 降到 0 | -| T2.7 | D7 品牌色退化 | 静态 `--iwb-brand` 不再 `= text2`,取 `seedAccent`;`--iwb-edge-hot` 同步 | 主按钮与次要文字色不同 | -| T2.8 | D8 无状态层 | 新增 `--iwb-state-hover/-pressed/-disabled/-selected` 与 `--iwb-focus-ring`(2px + 2px offset);`:focus-visible` 统一套用 | 键盘 Tab 全场可见焦点环 | -| T2.9 | D9 暗色 24 条硬编码 | 逐条换成对应语义 token(`#e0e0e0 → text`、`rgba(255,255,255,.5) → state-hover`、`#0f0f0f` 混色 → 派生 inset) | `.theme-dark` 里硬编码色行数 24 → 0 | +| T2.1a | D1③ 系统跟随不重算 | ✅ 3.26.43 已修 | — | +| T2.1 | D1 三写入者 | ✅ `.theme-dark` 颜色改为 derive 快照;结构层统一成一套 `color-mix`,`derive`/`apply` 都按同系数重算 | **没有删掉 `.theme-dark` 的颜色值**。计划说「颜色全部删,由 derive 统一写」,但那样 JS 执行前那一帧会退回 `:root` 的亮色 → 暗色用户每次启动闪白。改为「静态快照 = derive 输出」,并加守卫测试钉死 | +| T2.2 | D3 夹错表面 | ✅ `clampAgainst(fg, surfaces, min)`,13 个表面取最差 | 表面清单比计划多(把 hover/dockBg/chrome/plugin×4 也算进去),因为它们在 `style.css` 里都承载文字 | +| T2.3 | D4 text2 只保 3.2 | ✅ 提到 4.5 | **没有新增 `--iwb-color-text-tertiary`**:`textDim` 已经承担三级语义,多一个名字只会多一处要维护的映射 | +| T2.4 | D5 textDim 不可读 | ✅ 退一步后夹到 3.0 | 同上,复用 `textDim` | +| T2.5 | 节点标题在画布上 1.9:1 | ✅ 新增 `--iwb-color-text-on-canvas`(对 canvas 按 6:1 派生) | **保留 `opacity:.8`**。计划说去掉,但 opacity 同时承担「未选中 vs 选中」的视觉差异,去掉就得另找状态表达 —— 改成把对比度目标提到 6:1 抵消混色衰减,一举两得 | +| T2.6 | D6 layer 方向翻转 + 一词多义 | ✅ `layer` 固定为 inset(两套主题都比 panel 暗);hover→`--iwb-hover`、浮层→`--iwb-bg-menu` | **`var(--iwb-layer)` 没有降到 0**(现 49 处)。计划要拆成 4 个语义并清零,但其中 chip/端口/小标签与「凹槽」是同一层,硬拆只会造出两个值几乎一样的 token。实际拆了**两条方向性错误**的(hover 会变暗、浮层会变暗),剩下的确实是 inset | +| T2.7 | D7 品牌色退化 | ✅ `--iwb-brand` 取 seedAccent;拆 `--iwb-brand-text` | **多拆了一个 brand-text**:计划只改 `--iwb-brand` 的值,但它在暗色下当文字只有 3.9:1 —— 填充和文字是两个角色,一个值满足不了 | +| T2.8 | D8 无状态层 | ✅ 新增 `--iwb-focus-ring`,统一 3 处 + `:where()` 兜底 | **只做了焦点环,没做 state-hover/pressed/disabled 四件套**。那四个要连带替换 36 处散落的 `color-mix(6%~16%)`,属 M4 的批量迁移;先做焦点环是因为它是「完全没有」而不是「不统一」 | +| T2.9 | D9 暗色 24 条硬编码 | ✅ 删 8 组、改 token 3 组,剩 16 条 | 剩下 16 条全是节点预设底色(`data-bg="white|cyan|…"`)的暗色对位,是**独立于 token 的色板**,不该被 token 化 | -**M2 必须先于 M4 的理由**(写在这里以免以后有人调顺序):`--iwb-layer` 一词多义是 D6 的根因,拆语义必须发生在迁移之前;否则 59 处引用会被原样搬到新 token 上,等于把问题换个名字。 +**计划外新增(执行中发现的三处层次反转)**:nodeBg 比画布暗、border 与 nodeBg 撞色、首页卡片隐身。详见 `design-tokens.md` §1.8。 + +**新增守卫**:`tests/theme-static-snapshot-test.js` —— CSS 静态快照必须等于 `derive()` 输出(58 色值 × 2 套)。 + +**回滚**:M2 是一个 commit;`.theme-dark` 与 `:root` 的旧值都在 git 里,`git revert` 即回到「中灰暗色」。 -**回滚**:T2.x 每条独立 commit;`theme-tokens.js` 加 `LEGACY_TOKENS` 开关,一键回旧派生。 ### M3 单一源与导出(1d,零观感) diff --git a/docs/standards/design-tokens.md b/docs/standards/design-tokens.md index eeb4a1b..a31d7d3 100644 --- a/docs/standards/design-tokens.md +++ b/docs/standards/design-tokens.md @@ -149,6 +149,8 @@ ### 1.6 结论:优化是必要的,但顺序要反过来 +> **执行状态(2026-11-23)**:下表九条已全部修复,做法与实测数字见 §1.8。本节保留为「为什么必须先修色彩模型」的论证。 + | 缺陷 | 性质 | 加尺度 token 能解决吗 | |---|---|---| | D1 三写入者 / 系统切换不重算 | 架构 + 可见 bug | 不能 | @@ -183,6 +185,43 @@ 留在 3.26.44。 说明:**`--iwb-plugin-*` 那 12 个「未被 style.css 引用」的变量不是死 token**,它们是插件契约(`theme-tokens.js` 写、`plugins/**` 读),审计脚本的单文件口径会误判,已在 §7 的验收里注明口径。 +### 1.8 M2 色彩模型修复执行记录(2026-11-23,v3.26.44) + +九条缺陷全部落地。**这是本计划唯一一批「用户能看出变化」的改动**,单独占一个版本号。 + +| 缺陷 | 修法 | 结果 | +|---|---|---| +| **D1** 三写入者 | ①`:root`/`.theme-dark` 改成 derive 的**静态快照**(同一套值,只用来顶住 JS 执行前那一帧);②结构层 `chrome/homeBg/dockBg/dockHeadBg` 统一成 CSS `color-mix` 一套公式,`derive()` 与 `ui-appearance.apply()` 都按同一系数重算;③暗色块不再重复定义结构层(让 `:root` 的公式在 `html` 上重新求值) | 三处公式变一处;首屏不再跳变 | +| **D2** 同名两套值 | `.theme-dark` 从「中灰底 #757575 + 深字 #111」改为 derive 的暗色快照(近黑 + 浅字) | 切主题不再是「换了个产品」 | +| **D3** 只对 bg 夹紧 | 新增 `clampAgainst(fg, surfaces, min)`:文字对 **13 个承载表面**取最差者夹紧(bg/panel/inset/layer2/panel/nodeBg/hover/dockBg/chrome/plugin×4) | 暗色正文最低从 3.94 → **7.11** | +| **D4** text2 只保 3.2 | 提到 4.5(AA 正文),`RATIO.text2` | 亮 4.60 / 暗 4.68(原 3.49 / 3.34) | +| **D5** textDim 2.12 | 从 text2 退一步再夹到 3.0(AA 大字下限) | 亮 3.25 / 暗 3.14(原 2.12 / 2.25) | +| **D6** layer 语义反转 | `layer` 固定为「内嵌/凹槽」语义,两套主题都**比 panel 暗**(暗色 .66→.83);hover、浮层、胶囊从 `layer` 里拆出来,分别用 `--iwb-hover` / `--iwb-bg-menu` | 57 处引用重新归类:5 hover、3 浮层、其余仍是内嵌 | +| **D7** 品牌色退化 | `--iwb-brand` 恢复为强调色种子 `#6b7280`;另拆 `--iwb-brand-text`(按对比度夹紧,暗色 #a6aab2),34 处「文字/图标」引用点切换 | 主按钮与次要文字不再同值 | +| **D8** 无焦点环 | 新增 `--iwb-focus-ring`(2px,走 brand-text),统一 3 处各自发明的焦点样式,并用 `:where()` 低权重兜底补齐所有可聚焦元素 | Tab 走查不再出现 Chromium 默认蓝环 | +| **D9** 24 条暗色硬编码 | 能删的删(顶栏 `#e0e0e0` 6 组、status-err、input `#111`)、方向错的改 token(hover 白底→`color-mix(text 12%)`、nav 选中反色、logotext→`text-dim`)、`.iwb-task-refinfo` 的亮色硬编码 `#8a93a6` 也一并改 `text-dim` | 49 条规则里剩 16 条,全部是**节点预设底色的暗色对位**(`data-bg="white|cyan|…"`),与 token 无关,合理保留 | + +**同批修掉三个此前没人发现的层次反转**(都是「同一个 token 在两套主题里方向相反」的变体): + +1. **节点比画布暗**:`nodeBg` 与 `canvas` 各自独立 mix,暗色算出 `#242424` < 画布 `#313131` —— 卡片看着是凹进去的。改成相对画布派生(亮 72% / 暗 6% 往白走),`depth` 拉到 0/60 两端都保证浮起。 +2. **`border` 与 `nodeBg` 撞色**:改完 nodeBg 后两者都是 `#3d3d3d`,暗色节点边框直接消失。暗色 `border` 系数 0.52 → 0.60(`#333333`)。 +3. **首页卡片隐身**:`homeBg` 暗色算出 `#1d1d1d`,比 panel `#1c1c1c` 还亮,于是卡片 52/48 混完等于背景。改 `homeBg` 暗色分支(0.35→0.12)+ 卡片改用浮起层 `--iwb-bg-menu`。 + +**新增 4 个 token**(都进了静态快照与守卫): + +| token | 语义 | 亮 | 暗 | +|---|---|---|---| +| `--iwb-brand-text` | 品牌色的文字/图标版(按对比度夹紧) | `#575d69` | `#a6aab2` | +| `--iwb-color-text-on-canvas` | 画布上的文字(对 canvas 按 6:1 派生,抵消 `opacity .8`) | `#404040` | `#b2b2b2` | +| `--iwb-bg-menu` | 浮层底(右键菜单/更多菜单/确认框/首页卡片) | `#fefefe` | `#3c3c3c` | +| `--iwb-focus-ring` | 键盘焦点环(`color-mix` 表达式,随主题) | 由 `brand-text` 派生 | 同左 | + +**新增守卫 `tests/theme-static-snapshot-test.js`**:逐值比对 CSS 静态快照与 `derive()` 输出(58 个色值 × 亮暗两套)。 +它在本批里当场抓到两处我自己漏同步的地方(暗色 `nodeBg` 与 `brand-text`),这正是这道守卫存在的意义 —— +「改派生公式忘同步 CSS」是这套双写模型最容易犯的错,靠人记是记不住的。 + +**已知限制**:`depth` 拉到 60 且暗色时,画布 `#676767` / 节点 `#707070` 都处在中等亮度,text(7:1) 与 text2(4.5:1) 的可选区间被压到接近纯白(`#f6f6f6` / `#f4f4f4`),层级感会变弱。默认 `depth=22` 不受影响。 + ## 2. 目标架构 ### 2.1 三层模型(与 Primer / Ant Design v5 / Radix 同一套骨架) @@ -556,7 +595,7 @@ L2 **只准这 8 个**(防止语义名爆炸): | 指标 | 现状 | S2 结束目标 | 长期 | |---|---|---|---| -| 未定义却引用的变量 | 7 | 0 | 0(闸门保证) | +| 未定义却引用的变量 | **0**(M1 已达成) | 0 | 0(闸门保证) | | `--sp-*` 采用次数 | 0 | ≥300 | — | | 字号写死处数 | 281 | ≤60 | ≤20 | | 圆角写死处数 | 164 | ≤40 | ≤10 | @@ -565,7 +604,7 @@ L2 **只准这 8 个**(防止语义名爆炸): | z-index 取值种类 | 42 | 9 | 9 | | 字号档数 | 19 | 8 | 8 | | 插件白名单文件 | 4 | 2 | 0 | -| 亮/暗截图回归 | 无基线 | 每批 0 diff | 持续 | +| 亮/暗截图回归 | **12 张基线**(M0 已建立) | 每批 0 diff | 持续 | --- @@ -600,6 +639,8 @@ L2 **只准这 8 个**(防止语义名爆炸): 裁定后本文状态为「生效」,`docs/plans/design-tokens-rollout.md` 的 M0 决策项视为完成。 +**执行进度**:决定 ④ 的两个版本都已落地 —— 3.26.43 放 D1③(系统跟随重算)+ M1 清账;3.26.44 放 D1①②/D2–D9。详见 §1.7、§1.8。 + --- ## 附:复核命令 diff --git a/package.json b/package.json index cf558dc..8d809fd 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "app:build": "tauri build", "lint": "eslint src app.js", "test": "node tests/relay-task-graph-fixture-test.js && node tests/plugin-style-node-test.js && node tests/inherit-text-test.js", - "test:unit": "node tests/plugin-archive-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/appearance-v2-test.js && node tests/image-prompt-cover-test.js && node tests/unit-test.js && node tests/canvas-actions-test.js && node tests/canvas-performance-test.js && node tests/canvas-drag-performance-test.js && node tests/resize-observer-performance-test.js && node tests/node-drag-jank-test.js && node tests/edge-graph-performance-test.js && node tests/persistence-export-images-test.js && node tests/settings-hotkeys-size-presets-test.js && node tests/custom-size-validation-test.js && node tests/image-node-performance-test.js && node tests/drag-frame-performance-test.js && node tests/canvas-edge-memo-test.js && node tests/canvas-node-transform-test.js && node tests/canvas-dot-zoom-test.js && node tests/duplicate-ws-fresh-source-test.js && node tests/single-canvas-shell-test.js && node tests/navigation-layout-test.js && node tests/home-canvas-library-test.js && node tests/left-resource-layout-test.js && node tests/interface-hierarchy-test.js && node tests/three-page-layout-test.js && node tests/page-chrome-regression-test.js && node tests/task-cache-test.js && node tests/storage-config-shape-test.js && node tests/storage-zip-test.js && node tests/canvas-node-factory-test.js && node tests/runtime-error-test.js && node tests/runtime-lifecycle-test.js && node tests/runtime-fetch-test.js && node tests/runtime-channel-test.js && node tests/runtime-boundary-test.js && node tests/runtime-record-test.js && node tests/runtime-recovery-test.js && node tests/runtime-diagnostic-record-test.js && node tests/runtime-metrics-test.js && node tests/runtime-run-context-test.js && node tests/runtime-execution-context-test.js && node tests/storage-gc-canvas-refs-test.js && node tests/storage-health-test.js && node tests/generation-state-test.js && node tests/canvas-store-test.js && node tests/storage-result-test.js && node tests/storage-local-test.js && node tests/storage-domain-test.js && node tests/storage-runtime-test.js && node tests/storage-indexeddb-test.js && node tests/generation-scheduler-test.js && node tests/gallery-query-test.js && node tests/gallery-hydration-test.js && node tests/image-blob-store-test.js && node tests/image-preview-derive-test.js && node tests/image-format-test.js && node tests/clipboard-graph-test.js && node tests/clipboard-graph-fallback-test.js && node tests/image-admit-test.js && node tests/image-dedupe-test.js && node tests/clipboard-kind-test.js && node tests/clipboard-paste-test.js && node tests/clipboard-copy-test.js && node tests/paste-once-test.js && node tests/list-e2e-specs-test.js && node tests/desktop-csp-loopback-test.js && node tests/architecture-boundary-guard-test.js && node tests/plugin-host-test.js && node tests/plugin-data-test.js && node tests/plugin-loader-test.js && node tests/plugin-bundle-test.js && node tests/plugin-install-test.js && node tests/plugin-gallery-render-test.js && node tests/plugin-gallery-recovery-test.js && node tests/plugin-gallery-ux-test.js && node tests/plugin-grouplib-render-test.js && node tests/plugin-promptlib-render-test.js && node tests/image-compress-test.js && node tests/storage-fallback-indexeddb-test.js && node tests/canvas-normalize-test.js && node tests/canvas-geometry-test.js && node tests/canvas-history-test.js && node tests/canvas-ops-test.js && node tests/canvas-text-test.js && node tests/history-store-test.js && node tests/plugin-integrity-test.js && node tests/workspace-sessions-store-test.js && node tests/workspace-list-test.js && node tests/workspace-purge-test.js && node tests/provider-ping-test.js && node tests/runtime-diagnostics-hotpath-test.js && node tests/storage-log-failure-test.js && node tests/storage-convergence-test.js && node tests/swallow-wiring-test.js && node tests/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js", + "test:unit": "node tests/plugin-archive-test.js && node tests/plugin-files-policy-test.js && node tests/theme-plugin-tokens-test.js && node tests/theme-static-snapshot-test.js && node tests/appearance-v2-test.js && node tests/image-prompt-cover-test.js && node tests/unit-test.js && node tests/canvas-actions-test.js && node tests/canvas-performance-test.js && node tests/canvas-drag-performance-test.js && node tests/resize-observer-performance-test.js && node tests/node-drag-jank-test.js && node tests/edge-graph-performance-test.js && node tests/persistence-export-images-test.js && node tests/settings-hotkeys-size-presets-test.js && node tests/custom-size-validation-test.js && node tests/image-node-performance-test.js && node tests/drag-frame-performance-test.js && node tests/canvas-edge-memo-test.js && node tests/canvas-node-transform-test.js && node tests/canvas-dot-zoom-test.js && node tests/duplicate-ws-fresh-source-test.js && node tests/single-canvas-shell-test.js && node tests/navigation-layout-test.js && node tests/home-canvas-library-test.js && node tests/left-resource-layout-test.js && node tests/interface-hierarchy-test.js && node tests/three-page-layout-test.js && node tests/page-chrome-regression-test.js && node tests/task-cache-test.js && node tests/storage-config-shape-test.js && node tests/storage-zip-test.js && node tests/canvas-node-factory-test.js && node tests/runtime-error-test.js && node tests/runtime-lifecycle-test.js && node tests/runtime-fetch-test.js && node tests/runtime-channel-test.js && node tests/runtime-boundary-test.js && node tests/runtime-record-test.js && node tests/runtime-recovery-test.js && node tests/runtime-diagnostic-record-test.js && node tests/runtime-metrics-test.js && node tests/runtime-run-context-test.js && node tests/runtime-execution-context-test.js && node tests/storage-gc-canvas-refs-test.js && node tests/storage-health-test.js && node tests/generation-state-test.js && node tests/canvas-store-test.js && node tests/storage-result-test.js && node tests/storage-local-test.js && node tests/storage-domain-test.js && node tests/storage-runtime-test.js && node tests/storage-indexeddb-test.js && node tests/generation-scheduler-test.js && node tests/gallery-query-test.js && node tests/gallery-hydration-test.js && node tests/image-blob-store-test.js && node tests/image-preview-derive-test.js && node tests/image-format-test.js && node tests/clipboard-graph-test.js && node tests/clipboard-graph-fallback-test.js && node tests/image-admit-test.js && node tests/image-dedupe-test.js && node tests/clipboard-kind-test.js && node tests/clipboard-paste-test.js && node tests/clipboard-copy-test.js && node tests/paste-once-test.js && node tests/list-e2e-specs-test.js && node tests/desktop-csp-loopback-test.js && node tests/architecture-boundary-guard-test.js && node tests/plugin-host-test.js && node tests/plugin-data-test.js && node tests/plugin-loader-test.js && node tests/plugin-bundle-test.js && node tests/plugin-install-test.js && node tests/plugin-gallery-render-test.js && node tests/plugin-gallery-recovery-test.js && node tests/plugin-gallery-ux-test.js && node tests/plugin-grouplib-render-test.js && node tests/plugin-promptlib-render-test.js && node tests/image-compress-test.js && node tests/storage-fallback-indexeddb-test.js && node tests/canvas-normalize-test.js && node tests/canvas-geometry-test.js && node tests/canvas-history-test.js && node tests/canvas-ops-test.js && node tests/canvas-text-test.js && node tests/history-store-test.js && node tests/plugin-integrity-test.js && node tests/workspace-sessions-store-test.js && node tests/workspace-list-test.js && node tests/workspace-purge-test.js && node tests/provider-ping-test.js && node tests/runtime-diagnostics-hotpath-test.js && node tests/storage-log-failure-test.js && node tests/storage-convergence-test.js && node tests/swallow-wiring-test.js && node tests/workbench-logic-test.js && node tests/storage-autobackup-test.js && node tests/storage-outputs-mutate-test.js && node tests/sync-facts-guard-test.js && node tests/e2e-fixed-waits-ratchet-test.js && node tests/shell-render-behavior-test.js && node tests/canvas-meta-notice-behavior-test.js && node tests/source-text-ratchet-test.js && node tests/plugin-theme-contract-test.js && node tests/prompt-md-roundtrip-test.js && node tests/generation-results-store-test.js && node tests/out-groups-order-test.js && node tests/native-overlay-park-test.js && node tests/ui-dock-sanitize-test.js && node tests/ui-minimap-fit-test.js && node tests/ui-workbench-hooks-test.js", "test:diagnostics": "node tests/runtime-diagnostics-hotpath-test.js", "test:facts": "node tests/architecture-facts-guard-test.js && node tests/release-records-test.js", "plugins:gc": "node scripts/plugins-publish.mjs --gc", diff --git a/scripts/token-audit.js b/scripts/token-audit.js index 9c650cb..e6b1941 100644 --- a/scripts/token-audit.js +++ b/scripts/token-audit.js @@ -137,22 +137,31 @@ if (process.argv.includes('--contrast')) { const SURFACES = ['bg', 'panel', 'layer', 'layer2', 'nodeBg', 'canvasBg', 'pluginSurface', 'pluginCard'] for (const dark of [false, true]) { const t = T.derive(T.DEFAULTS, dark) - console.log('\n### ' + (dark ? '暗色' : '亮色') + ':文字对各表面(≥4.5 达标)\n') + const MINS = { text: T.RATIO.text, text2: T.RATIO.text2, textDim: T.RATIO.dim } + console.log('\n### ' + (dark ? '暗色' : '亮色') + ':文字对各表面(text≥' + MINS.text + ' / text2≥' + MINS.text2 + ' / textDim≥' + MINS.textDim + ')\n') console.log('| 表面 | text | text2 | textDim |\n|---|---|---|---|') for (const s of SURFACES) { const row = ['text', 'text2', 'textDim'].map((f) => { const v = T.contrast(t[f], t[s]).toFixed(2) - return Number(v) < 4.5 ? '**' + v + '**' : v + return Number(v) < MINS[f] ? '**' + v + '**' : v }) console.log('| ' + s + ' | ' + row.join(' | ') + ' |') } } - console.log('\n### 同名 token:静态 CSS vs derive()(暗色)\n') - console.log('| token | `:root` 静态 | derive 默认 |\n|---|---|---|') - const STATIC_DARK = { '--iwb-bg': '#757575', '--iwb-panel': '#a5a5a5', '--iwb-layer': '#9c9c9c', '--iwb-layer2': '#b0b0b0', '--iwb-node-bg': '#b3b3b3', '--iwb-text': '#111111', '--iwb-text2': '#2f2f2f' } + /* 静态快照 vs derive():v3.26.44 起两者必须完全一致(D2)。 + * 之前这里硬编码着旧的「中灰底」值,脚本自己成了过时信息的来源 —— 现在从 .theme-dark 实时解析。 */ + console.log('\n### 静态快照 vs derive()(暗色)—— 必须一致\n') + console.log('| token | `.theme-dark` 静态 | derive 默认 | 一致 |\n|---|---|---|---|') + const darkBlock = (css.match(/\.theme-dark\s*\{([\s\S]*?)\n\}/) || [, ''])[1].replace(/\/\*[\s\S]*?\*\//g, '') + const statDark = {} + for (const m of darkBlock.matchAll(/--(?:iwb-)?([a-z0-9-]+)\s*:\s*(#[0-9a-fA-F]{6})\s*;/g)) statDark[m[1]] = m[2].toLowerCase() const d = T.derive(T.DEFAULTS, true) - const KEYS = { '--iwb-bg': 'bg', '--iwb-panel': 'panel', '--iwb-layer': 'layer', '--iwb-layer2': 'layer2', '--iwb-node-bg': 'nodeBg', '--iwb-text': 'text', '--iwb-text2': 'text2' } - for (const [k, key] of Object.entries(KEYS)) console.log('| `' + k + '` | `' + STATIC_DARK[k] + '` | `' + d[key] + '` |') + const KEYS = { bg: 'bg', panel: 'panel', layer: 'layer', layer2: 'layer2', 'node-bg': 'nodeBg', text: 'text', text2: 'text2', 'text-dim': 'textDim' } + for (const [k, key] of Object.entries(KEYS)) { + const sv = statDark[k] || '(表达式)' + const ok = sv === d[key] + console.log('| `--iwb-' + k + '` | `' + sv + '` | `' + d[key] + '` | ' + (ok ? '✓' : '**不一致**') + ' |') + } process.exit(0) } diff --git a/src/theme-tokens.js b/src/theme-tokens.js index feb9245..035d17e 100644 --- a/src/theme-tokens.js +++ b/src/theme-tokens.js @@ -1,4 +1,4 @@ -/* theme-tokens.js —— 配色自动适配(v3.25.81,P1) +/* theme-tokens.js —— 配色自动适配(v3.26.44:色彩模型修正 D2–D6) * * 用户裁定:只定 4 个「种子」,其余颜色由函数派生: * ① 中性基调 seedNeutral(一个中灰) @@ -8,8 +8,10 @@ * * 派生规则: * · 亮色:往白里 mix(越靠表面越白),画布往灰里 mix - * · 暗色:往黑里 mix(同一套语义名,方向相反) - * · 文本对表面做 4.5:1 对比度夹紧(不够就自动加深/提亮) + * · 暗色:往黑里 mix(同一套语义名,方向同向 —— 见下方 layer 注释) + * · 文字对**全部承载表面**做对比度夹紧(旧实现只对 bg,暗色正文在 layer 上只有 3.94:1) + * + * 对比度目标集中在 RATIO,不要在别处再写 4.5 / 3.2 这类魔数。 * 产出沿用现有 --iwb-* 变量名,CSS 不需要重写。 */ ;(function (global) { @@ -46,14 +48,37 @@ const l2 = Math.min(lum(a), lum(b)) return (l1 + 0.05) / (l2 + 0.05) } - // 文本对表面做对比度夹紧:不够就朝「远离表面」的方向继续 mix + + /* 对比度目标(WCAG 2.1) + * text 7.0 正文:AAA,界面里被读得最多的字 + * text2 4.5 次要文字 / 标签 / 说明:AA 正文 + * dim 3.0 占位符 / 禁用 / 装饰:AA 大字下限(不再往 2.1 掉) + * canvas 6.0 画布上的节点标题:它还叠了 opacity .8,留 6.0 的余量保证合成后仍 ≥4.5 + * onBrand 4.5 品牌色上的文字 */ + const RATIO = { text: 7, text2: 4.5, dim: 3, canvas: 6, onBrand: 4.5 } + + // 对单色表面夹紧:不够就朝「远离表面」的方向继续 mix function clampText (fg, bg, minRatio) { + return clampAgainst(fg, [bg], minRatio) + } + + /* 对**一整套表面**夹紧:约束取「最差的那个表面」。 + * 旧实现只传 bg,于是暗色下 --iwb-text 在 layer(3.94) / nodeBg(4.38) / pluginCard(3.94) + * 全都不达标 —— 而它在 style.css 里出现 200+ 次。 */ + function clampAgainst (fg, surfaces, minRatio) { const min = Number(minRatio) || 4.5 + const list = (Array.isArray(surfaces) ? surfaces : [surfaces]).filter(Boolean) + if (!list.length) return fg let out = fg - const away = lum(bg) > 0.5 ? '#000000' : '#ffffff' - for (let i = 0; i < 12; i++) { - if (contrast(out, bg) >= min) break - out = mix(out, away, 0.12) + const away = lum(list[0]) > 0.5 ? '#000000' : '#ffffff' + for (let i = 0; i < 60; i++) { + let worst = Infinity + for (let j = 0; j < list.length; j++) { + const r = contrast(out, list[j]) + if (r < worst) worst = r + } + if (worst >= min - 0.005) break + out = mix(out, away, 0.05) } return out } @@ -68,76 +93,121 @@ const d = !!dark const t = d ? '#000000' : '#ffffff' - // 表面阶:亮色往白、暗色往黑 + // —— 表面阶:亮色往白、暗色往黑 —— const surface0 = mix(N, t, d ? 0.86 : 0.94) const surface1 = mix(N, t, d ? 0.78 : 0.99) const surface2 = mix(N, t, d ? 0.70 : 0.90) const surface3 = mix(N, t, d ? 0.64 : 0.84) // 画布:亮色更深、暗色略亮(与 UI 拉开层次) const canvas = d ? mix(surface0, '#ffffff', depth / 100 * 0.6) : mix(surface0, '#000000', depth / 100 * 0.9) - const border = mix(N, t, d ? 0.52 : 0.52) + /* 暗色 0.52 会算出 #3d3d3d,与新的 nodeBg 撞成同色 → 节点边框消失。 + * 暗色压到 0.60(#333333)保证边框比卡片底暗一档;亮色不变。 */ + const border = mix(N, t, d ? 0.60 : 0.52) const border2 = mix(N, t, d ? 0.40 : 0.34) - const layer = mix(N, t, d ? 0.66 : 0.92) - const nodeBg = mix(N, t, d ? 0.72 : 0.88) - const textBase = mix(N, t, d ? 0.06 : 0.06) - const text = clampText(textBase, surface0, 4.5) - const text2 = clampText(mix(N, t, d ? 0.30 : 0.34), surface0, 3.2) + /* 内嵌层(--iwb-layer)。旧实现亮色 0.92、暗色 0.66: + * 亮色 panel(.99) > layer(.92) → layer 更暗 = 内嵌 ✓ + * 暗色 panel(.78) < layer(.66) → layer 更亮 = 凸起 ✗ + * 同一个 token 在两套主题里表达相反的层次(D6)。改成暗色 .83,两个方向都「挖进去」。 */ + const inset = mix(N, t, d ? 0.83 : 0.92) + /* 节点卡片必须始终「浮在画布上」。旧实现把 nodeBg 与 canvas 各自独立 mix, + * 暗色下算出来 nodeBg(#242424) 比 canvas(#313131) 还暗 —— 卡片看着是凹进去的。 + * 改成相对画布派生、两套主题都往白走:亮色 72%、暗色 6%, + * depth 拉到 0/60 两端也都保证 nodeBg 不低于 canvas。 */ + const nodeBg = mix(canvas, '#ffffff', d ? 0.06 : 0.72) + + /* —— 结构层(先算表面,文字要用它们做夹紧) —— + * 这里的四个公式必须与 style.css 的 :root color-mix 完全一致: + * 同一批 token 此前有三套写法(CSS 用 chrome / derive 用 surface3 / apply 用 layer), + * 于是「有没有动过配色」会让停靠栏颜色不一样(D1 三写入者的后果)。 */ + const chrome = mix(surface0, canvas, 0.4) + /* 首页底:亮色要明显暗于页面底(形成「画布区」),暗色不能超过 panel —— + * 旧公式暗色算出 #1d1d1d 比 panel(#1c1c1c) 还亮,卡片 52/48 混完等于背景,整个列表「隐身」。 */ + const homeBg = mix(surface0, canvas, d ? 0.12 : 0.35) + const dockBg = mix(chrome, canvas, 0.45) + const dockHeadBg = mix(surface1, dockBg, 0.45) + const hover = d ? mix(surface0, '#ffffff', 0.10) : mix(surface0, '#000000', 0.055) + // 插件历史变量补洞:此前未定义,插件只能吃硬编码兜底(暗色下会突然白底) + const surface = surface1 + const pluginSurface = d ? mix(surface0, '#ffffff', 0.07) : mix(surface1, '#000000', 0.035) + const pluginCard = d ? mix(surface0, '#ffffff', 0.11) : surface1 + const pluginInset = d ? mix(surface0, '#000000', 0.12) : mix(surface1, '#000000', 0.075) + const pluginHover = d ? mix(surface0, '#ffffff', 0.16) : mix(surface1, '#000000', 0.11) + /* 浮层底(右键菜单 / 更多菜单 / 确认框)。浮层要「比它盖住的东西亮」: + * 亮色直接用 panel(最白);暗色如果也用 panel(#1c1c1c),浮在画布(#313131)上反而更暗 —— + * 看着像挖了个坑。暗色往白提 14% → #3c3c3c,稳定亮于画布且与节点同档。 */ + const menuBg = d ? mix(surface1, '#ffffff', 0.14) : surface1 + + /* 承载文字的整套表面。canvas 不在内 —— 画布上只有节点标题,另有专用色。 + * 顺序无关,clampAgainst 取最差者。 */ + const textSurfaces = [surface0, surface1, inset, surface2, surface3, nodeBg, hover, dockBg, chrome, pluginSurface, pluginCard, pluginInset, pluginHover] + + const text = clampAgainst(mix(N, t, 0.06), textSurfaces, RATIO.text) + const text2 = clampAgainst(mix(N, t, d ? 0.30 : 0.34), textSurfaces, RATIO.text2) + // 三级文字:从二级往表面方向退一步,再夹到 dim 下限(保证「更淡但还看得见」) + const textDim = clampAgainst(mix(text2, surface0, 0.34), textSurfaces, RATIO.dim) + // 画布上的节点标题:对 canvas 夹紧,且预留 opacity .8 的余量 + const canvasText = clampAgainst(mix(N, t, d ? 0.30 : 0.34), [canvas], RATIO.canvas) + + // v3.26.42:节点文字与界面文字分家(外观面板可分别微调) + const nodeText = text + const nodeText2 = clampAgainst(mix(N, t, d ? 0.30 : 0.34), [nodeBg, inset], RATIO.text2) + /* tint:所有「以文字色做半透明底色/描边」的基色。刻意**不跟随**文字覆盖 —— + * 用户把字调深/调浅时,悬停底、标签底、分隔线不应跟着一起变(否则调字等于重排整套灰阶)。 */ + const tint = text + const brand = A + /* 品牌色的两个角色必须分开: + * brand —— 填充(主按钮底、选中框、端口环),要够深以承白字 + * brandText —— 文字/图标,要够亮以在深底上读得清 + * 旧实现只有一个,暗色下作文字只有 3.9:1(D7 的延续) */ + const brandText = clampAgainst(A, textSurfaces, RATIO.text2) const brandHover = mix(A, d ? '#ffffff' : '#000000', 0.14) const edgeHot = d ? mix(A, '#ffffff', 0.25) : A const gridDot = mix(N, t, d ? 0.36 : 0.30) - // v3.26.42:节点文字与界面文字分家(外观面板可分别微调) - const nodeText = text - const nodeText2 = text2 - // tint:所有「以文字色做半透明底色/描边」的基色。刻意**不跟随**文字覆盖 —— - // 用户把字调深/调浅时,悬停底、标签底、分隔线不应跟着一起变(否则调字等于重排整套灰阶)。 - const tint = text - // 插件历史变量补洞:--iwb-surface / --iwb-hover / --iwb-text-dim 此前未定义, - // 插件只能吃硬编码兜底(暗色下会突然变白底)。按同一灰阶派生,插件零改动即跟随主题。 - const surface = surface1 - const hover = d ? mix(surface0, '#ffffff', 0.10) : mix(surface0, '#000000', 0.055) - const textDim = mix(text2, surface0, 0.35) // 语义色:色相固定,明度随主题调整(暗色提亮一档,避免发闷) const err = d ? mix('#ef4444', '#ffffff', 0.18) : '#ef4444' const ok = d ? mix('#22c55e', '#ffffff', 0.18) : '#22c55e' const warn = d ? mix('#d97706', '#ffffff', 0.22) : '#d97706' // 品牌色上的文字:按对比度自动选黑/白 - const onBrand = contrast('#ffffff', brand) >= 4.5 ? '#ffffff' : '#1c2333' + const onBrand = contrast('#ffffff', brand) >= RATIO.onBrand ? '#ffffff' : '#1c2333' return { err, ok, warn, onBrand, bg: surface0, panel: surface1, - layer, + layer: inset, layer2: d ? surface1 : '#ffffff', nodeBg, canvasBg: canvas, - chrome: mix(surface0, canvas, 0.4), - homeBg: mix(surface0, canvas, 0.35), - dockBg: mix(surface3, canvas, 0.45), + chrome, + homeBg, + dockBg, // v3.26.19:顶栏比停靠栏更浅(向面板色靠 55%),不再压暗 - dockHeadBg: mix(mix(surface3, canvas, 0.45), surface0, 0.55), + dockHeadBg, border, border2, text, text2, textDim, + canvasText, nodeText, nodeText2, tint, surface, hover, + menuBg, brand, + brandText, brandHover, edge: border2, edgeHot, gridDot, - // v3.26.20:插件通用灰(中性灰,不带蓝调;暗色模式跟随主题,不再固定浅色) - pluginSurface: d ? mix(surface0, '#ffffff', 0.07) : mix(surface1, '#000000', 0.035), - pluginCard: d ? mix(surface0, '#ffffff', 0.11) : surface1, - pluginInset: d ? mix(surface0, '#000000', 0.12) : mix(surface1, '#000000', 0.075), - pluginHover: d ? mix(surface0, '#ffffff', 0.16) : mix(surface1, '#000000', 0.11), + // 亮色层 + pluginSurface, + pluginCard, + pluginInset, + pluginHover, } } @@ -163,12 +233,15 @@ s('--iwb-text', tokens.text) s('--iwb-text2', tokens.text2) s('--iwb-text-dim', tokens.textDim) + s('--iwb-color-text-on-canvas', tokens.canvasText) s('--iwb-node-text', tokens.nodeText) s('--iwb-node-text2', tokens.nodeText2) s('--iwb-tint', tokens.tint) s('--iwb-surface', tokens.surface) s('--iwb-hover', tokens.hover) + s('--iwb-bg-menu', tokens.menuBg) s('--iwb-brand', tokens.brand) + s('--iwb-brand-text', tokens.brandText) s('--iwb-edge', tokens.edge) s('--iwb-edge-hot', tokens.edgeHot) s('--iwb-grid-dot', tokens.gridDot) @@ -178,5 +251,5 @@ s('--iwb-on-brand', tokens.onBrand) } - global.IWBThemeTokens = { DEFAULTS, derive, applyTo, mix, contrast, clampText } + global.IWBThemeTokens = { DEFAULTS, RATIO, derive, applyTo, mix, contrast, clampText, clampAgainst } })(typeof window !== 'undefined' ? window : globalThis) diff --git a/src/ui-appearance.js b/src/ui-appearance.js index af32103..3337e94 100644 --- a/src/ui-appearance.js +++ b/src/ui-appearance.js @@ -189,16 +189,18 @@ // 否则会出现「暖色面板 + 冷灰顶栏」「暖色面板 + 冷灰插件卡片」的割裂 const M = T.mix if (typeof M === 'function') { + // 与 theme-tokens.derive() 及 style.css :root 的 color-mix 保持同一套公式,不许第三套 final.chrome = M(final.bg, final.canvasBg, 0.4) final.homeBg = M(final.bg, final.canvasBg, 0.35) - final.dockBg = M(final.layer, final.canvasBg, 0.45) - final.dockHeadBg = M(final.dockBg, final.bg, 0.55) + final.dockBg = M(final.chrome, final.canvasBg, 0.45) + final.dockHeadBg = M(final.panel, final.dockBg, 0.45) final.surface = final.panel - final.pluginCard = final.panel + final.pluginCard = dark ? M(final.bg, '#ffffff', 0.11) : final.panel final.pluginSurface = dark ? M(final.bg, '#ffffff', 0.07) : M(final.panel, '#000000', 0.035) final.pluginInset = dark ? M(final.bg, '#000000', 0.12) : M(final.panel, '#000000', 0.075) final.pluginHover = dark ? M(final.bg, '#ffffff', 0.16) : M(final.panel, '#000000', 0.11) final.hover = dark ? M(final.bg, '#ffffff', 0.10) : M(final.bg, '#000000', 0.055) + final.menuBg = dark ? M(final.panel, '#ffffff', 0.14) : final.panel } // tint 恒取派生文字色:调字不改悬停/标签底色(否则调一个字等于重排整套灰阶) final.tint = tokens.tint diff --git a/style.css b/style.css index b067b0d..1abd1ba 100644 --- a/style.css +++ b/style.css @@ -1,8 +1,20 @@ /* 生图工作台 Image Workbench — 独立版样式(亮/暗主题手动切换,设置 → 通用 → 主题) * 亮色配色:节点背景灰、内容区(输入框/标题栏/参数区)白,保证文字清晰阅读 */ +/* ⚠ 本段是设计 token 的「静态快照」:颜色值必须等于 IWBThemeTokens.derive(DEFAULTS, false) + * 的输出。JS 未执行的那一帧用它顶住,跑完由 derive() 写内联同名变量 —— 两者一致才不会 + * 首屏跳一下。改派生公式后请同步这里,tests/theme-tokens-test.js 会比对并报错。 + * 结构层(chrome/home/dock)刻意用 color-mix 表达:公式与 derive 一致,换主题时 + * :root 的声明会在 html 元素上按新的 --iwb-bg/--iwb-canvas-bg 重新求值,自动跟随。 */ :root { - --iwb-bg: #f4f5f7; - --iwb-canvas-bg: #d9dbde; + /* —— 表面阶(亮色往白里 mix) —— */ + --iwb-bg: #f7f7f7; + --iwb-canvas-bg: #c6c6c6; + /* --iwb-layer 是「内嵌层」:面板里的凹槽(任务条/引用块/输入框)。 + 两个主题里都必须比 --iwb-panel 暗 —— 旧实现暗色是「更亮」,同一个 token 表达相反层次(D6)。 */ + --iwb-layer: #f5f5f5; + --iwb-layer2: #ffffff; + --iwb-panel: #fefefe; + --iwb-node-bg: #efefef; /* 顶部 chrome 色:页面底与画布之间的过渡层(标签条用)。 比 --iwb-bg 深一号、比画布浅 → 顶部亮带贴画布的对比减弱(v3.1.0 顶栏配色); 调深浅改下面 60/40 两个百分比即可(越往画布色靠,对比越弱) */ @@ -17,20 +29,18 @@ /* 左右停靠栏底色(v3.25.58):栏是「结构层」不是「浮层」,之前直接用 --iwb-panel(纯白), 比页面底还亮 ⇒ 亮色下与画布 1.39:1、暗色下 2.04:1,两侧像亮度泄漏。 这里把它排进既有灰阶 ramp(bg → chrome → home → canvas):取 chrome 与画布的中段, - 与标签条同级、只比画布亮一点点;两主题都用同一公式(chrome/canvas 本身随主题变)。 - 头部再深一档用「栏身 + 6% 黑」而不是往画布色混:暗色整条灰阶只有 #6F–#75, - 混画布色实测 ΔL 仅 0.006(看不见),黑色叠加在亮/暗下都能看出头部带(1.14:1 / 1.11:1)。 */ + 与标签条同级、只比画布亮一点点;两主题都用同一公式(chrome/canvas 本身随主题变)。 */ --iwb-dock-bg: color-mix(in srgb, var(--iwb-chrome) 55%, var(--iwb-canvas-bg) 45%); /* v3.26.19:顶栏底色比停靠栏更浅一档(原来是压暗 6%,现在向面板色靠 55%) */ --iwb-dock-head-bg: color-mix(in srgb, var(--iwb-panel) 55%, var(--iwb-dock-bg)); - --iwb-panel: #ffffff; - --iwb-layer: #f0f1f4; - --iwb-layer2: #ffffff; - --iwb-node-bg: #f1f3f6; - --iwb-border: #d5d9e0; - --iwb-border2: #b9bfca; - --iwb-brand: var(--iwb-text2); /* v3.1.0 全灰阶:原品牌蓝 → 同亮度中性灰(白字对比仍 ≥4.5:1) */ - --iwb-on-brand: #ffffff; /* v3.25.83:自动配色会按对比度改写为黑/白 */ + --iwb-border: #c2c2c2; + --iwb-border2: #ababab; + /* 品牌色 v3.26.44:从「等于次要文字色」恢复为真正的强调色种子(D7)。 + 主按钮用它做底,--iwb-on-brand 按对比度自动取黑/白。 */ + --iwb-brand: #6b7280; + /* 品牌色的文字版:按对比度夹紧(暗色会明显亮于填充色) */ + --iwb-brand-text: #575d69; + --iwb-on-brand: #ffffff; /* v3.25.85 插件主题契约:插件只能用这组别名(宿主负责让它们跟随主题/自动配色) */ --iwb-plugin-bg: var(--iwb-bg); --iwb-plugin-panel: var(--iwb-panel); @@ -39,10 +49,10 @@ --iwb-plugin-text: var(--iwb-text); --iwb-plugin-text2: var(--iwb-text2); /* 插件面板四层(v3.25.96):只提供取值,不做任何变量重指(3.25.89 的事故不再重演) */ - --iwb-plugin-surface: #f1f1f1; - --iwb-plugin-card: #ffffff; - --iwb-plugin-inset: #e9e9e9; - --iwb-plugin-hover: #dfdfdf; + --iwb-plugin-surface: #f5f5f5; + --iwb-plugin-card: #fefefe; + --iwb-plugin-inset: #ebebeb; + --iwb-plugin-hover: #e2e2e2; --iwb-plugin-brand: var(--iwb-brand); --iwb-plugin-on-brand: var(--iwb-on-brand); --iwb-plugin-err: var(--iwb-err); @@ -56,26 +66,38 @@ --iwb-edge-hot: var(--iwb-brand); --iwb-node-radius: 14px; --iwb-node-sel-w: 1px; - --iwb-grid-dot: #c9ccd6; + --iwb-grid-dot: #a6a6a6; --iwb-grid-size: 1.4px; --iwb-grid-gap: 22px; --iwb-grid-on: 1; /* 一级导航宽度:左停靠栏/工具栏让位都以它为基准(v3.25.59) */ --iwb-nav-w: 52px; - --iwb-text: #1c2333; - --iwb-text2: #4d5668; - --iwb-text-dim: #7b8494; + /* —— 文字三级(v3.26.44 重定):目标对比度见 IWBThemeTokens.RATIO + text 7:1(AAA 正文)/ text2 4.5:1(AA 次要)/ text-dim 3:1(辅助、占位) + 旧值只对 --iwb-bg 夹紧,暗色下正文在 layer/nodeBg/pluginCard 上只有 3.9–4.4(D3/D4/D5) */ + --iwb-text: #404040; + --iwb-text2: #5c5c5c; + --iwb-text-dim: #767676; + /* 画布上的文字专用色:节点标题画在画布上(透明底)再叠 opacity .8, + 复用 text2 实测只有 1.9:1。它只对 --iwb-canvas-bg 负责,不参与界面文字的灰阶 */ + --iwb-color-text-on-canvas: #404040; /* v3.26.42 外观 v2:节点文字与界面文字分家;tint 是「半透明文字底色」的基色(不随调字变化) */ - --iwb-node-text: #1c2333; - --iwb-node-text2: #4d5668; - --iwb-tint: #1c2333; + --iwb-node-text: #404040; + --iwb-node-text2: #6b6b6b; + --iwb-tint: #404040; /* 插件历史变量补洞:此前未定义,插件只能吃硬编码兜底(暗色下会突然白底) - @deprecated --iwb-surface:全仓零引用,且 derive() 不写它 → 一旦有人用,暗色下会是纯白底。 - 要用「卡片底」请用 --iwb-plugin-card / --iwb-layer;M3 起用 --iwb-bg-inset。保留仅为不打断未来引用。 */ - --iwb-surface: #ffffff; - --iwb-hover: #ececec; - --iwb-err: #e5484d; - --iwb-ok: #2f9e5f; + @deprecated --iwb-surface:全仓零引用。要用「卡片底」请用 --iwb-plugin-card / --iwb-layer; + M3 起用 --iwb-bg-inset。保留仅为不打断未来引用。 */ + --iwb-surface: #fefefe; + --iwb-hover: #e9e9e9; + /* 浮层底:亮色=面板色,暗色会比面板亮一档(见 theme-tokens 的 menuBg) */ + --iwb-bg-menu: #fefefe; + /* 键盘焦点环(v3.26.44 / D8):此前只有三处各自发明(brand 60% / tint 35% / tint 30%), + 其余可聚焦元素完全没有焦点反馈。统一成一个 token,颜色走 brand-text —— + 暗色下 brand 是填充色偏暗,画不出环。 */ + --iwb-focus-ring: 2px solid color-mix(in srgb, var(--iwb-brand-text) 70%, transparent); + --iwb-err: #ef4444; + --iwb-ok: #22c55e; --iwb-warn: #d97706; /* —— 设计 token 第一代(v3.1.0-stability2 起):间距 / 圆角 / 字号 / 阴影 / 过渡 —— 2026-11-23 审计结论:这套尺度 token **采用率约 0.5%**(`--sp-*` 被引用 0 次,而间距写死 644 处)。 @@ -92,30 +114,52 @@ --sh-lg: 0 12px 32px rgba(0, 0, 0, 0.24); --tr-fast: 0.1s ease-out; --tr-base: 0.2s ease-out; --tr-slow: 0.3s ease-out; /* @deprecated tr-base/tr-slow → M3 的 --iwb-motion-*(tr-fast 仍被引用) */ } -/* 暗色主题:html.theme-dark(设置 → 通用 → 主题 切换;不再跟随系统) */ +/* 暗色主题:html.theme-dark(设置 → 通用 → 主题 切换;不再跟随系统) + * ⚠ 同样是静态快照:这些值必须等于 IWBThemeTokens.derive(DEFAULTS, true) 的输出。 + * 旧版这里是「中灰底(#757575)+ 深字(#111)」的独立设计,与 derive 的「近黑底 + 浅字」 + * 同名不同值 —— 切主题等于换了个产品(D2)。现在两者统一为同一套派生结果。 + * 结构层(chrome/home/dock)不在这里重复定义::root 的 color-mix 公式会在本元素上 + * 按新的 --iwb-bg/--iwb-canvas-bg 重新求值,天然跟随。 */ .theme-dark { - /* 生图动效在暗色下必须"发亮":--iwb-brand 在暗色是近黑色,直接用它会让进度线/旋转环/流动渐变都变成"黑压灰"。 - 这里统一改成「亮色元素 + 深色轨道」,靠元素内部的明暗反差获得清晰度(灰底本身对不同色相的对比度有上限)。 */ + /* 生图动效在暗色下必须"发亮":--iwb-brand 是中性灰,直接用它会让进度线/旋转环/流动渐变 + 都糊在深底里。这里统一用「亮色元素 + 深色轨道」靠明暗反差获得清晰度。 */ --iwb-anim: #ffffff; - --iwb-anim-track: color-mix(in srgb, #101010 34%, transparent); + --iwb-anim-track: color-mix(in srgb, #ffffff 18%, transparent); --iwb-anim-glow: rgba(255, 255, 255, 0.72); --iwb-anim-tint: color-mix(in srgb, #ffffff 16%, transparent); - --iwb-anim-flow-a: color-mix(in srgb, #101010 26%, var(--iwb-layer)); - --iwb-anim-flow-b: color-mix(in srgb, #ffffff 62%, var(--iwb-layer)); - --iwb-bg: #757575; - --iwb-canvas-bg: #6f6f6f; - --iwb-panel: #a5a5a5; - --iwb-layer: #9c9c9c; - --iwb-layer2: #b0b0b0; - --iwb-node-bg: #b3b3b3; - --iwb-border: #4f4f4f; - --iwb-border2: #404040; - --iwb-brand: #1a1a1a; - --iwb-text: #111111; - --iwb-text2: #2f2f2f; - --iwb-err: #ff6368; - --iwb-ok: #4cc38a; - --iwb-warn: #f0a14a; + /* 旧值是「往 layer 里混 26% 近黑」,layer 从 #9c9c9c 变成 #161616 后,混出来几乎等于底色 + ⇒ 流动渐变左端不可见。改成从「比层亮 26%」到「比层亮 76%」,保持深→浅的流动方向。 */ + --iwb-anim-flow-a: color-mix(in srgb, #ffffff 26%, var(--iwb-layer)); + --iwb-anim-flow-b: color-mix(in srgb, #ffffff 76%, var(--iwb-layer)); + --iwb-bg: #121212; + --iwb-canvas-bg: #313131; + --iwb-layer: #161616; + --iwb-layer2: #1c1c1c; + --iwb-panel: #1c1c1c; + --iwb-node-bg: #3d3d3d; + --iwb-border: #333333; + --iwb-border2: #4d4d4d; + --iwb-brand: #6b7280; + --iwb-brand-text: #a6aab2; + --iwb-text: #d1d1d1; + --iwb-text2: #aaaaaa; + --iwb-text-dim: #8a8a8a; + --iwb-color-text-on-canvas: #b2b2b2; + --iwb-node-text: #d1d1d1; + --iwb-node-text2: #aaaaaa; + --iwb-tint: #d1d1d1; + --iwb-surface: #1c1c1c; + --iwb-hover: #2a2a2a; + --iwb-bg-menu: #3c3c3c; + --iwb-grid-dot: #525252; + --iwb-plugin-surface: #232323; + --iwb-plugin-card: #2c2c2c; + --iwb-plugin-inset: #101010; + --iwb-plugin-hover: #383838; + --iwb-err: #f26666; + --iwb-ok: #4acf7b; + --iwb-warn: #e1953d; + --iwb-on-brand: #ffffff; --sh-sm: 0 2px 8px rgba(0, 0, 0, 0.35); --sh-md: 0 6px 20px rgba(0, 0, 0, 0.45); --sh-lg: 0 12px 32px rgba(0, 0, 0, 0.6); @@ -177,10 +221,12 @@ button { font-family: inherit; } 高度恒定是气泡抬升公式 NODE_HEAD_H/NODE_HEAD_FB_GAP 成立的前提,故 .iwb-node-title 必须单行省略。 */ .iwb-node-head { display: flex; position: absolute; left: 0; bottom: 100%; align-items: center; gap: 5px; height: 22px; max-width: 190px; margin-bottom: 8px; padding: 0 7px; cursor: move; background: transparent; border-radius: 7px; font-weight: 600; } .iwb-node-head:hover { background: var(--iwb-layer2); } -.iwb-node-headicon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--iwb-text2); opacity: .75; } +/* 标题带画在画布上(透明底),所以不能吃节点/界面的文字色 —— 用画布专用色。 + 专用色对 --iwb-canvas-bg 按 6:1 派生,抵消 opacity .8 合成后的衰减;实测合成后 ≥4.5。 */ +.iwb-node-headicon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--iwb-color-text-on-canvas, var(--iwb-text2)); opacity: .75; } .iwb-node-headicon .iwb-ic { width: 13px; height: 13px; } /* 标题统一灰色(不再按节点类型着色;类型由左侧图标区分) */ -.iwb-node-title { font-size: 12px; color: var(--iwb-text2); opacity: 0.8; font-weight: 500; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .15s, font-weight .15s; } +.iwb-node-title { font-size: 12px; color: var(--iwb-color-text-on-canvas, var(--iwb-text2)); opacity: 0.8; font-weight: 500; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .15s, font-weight .15s; } .iwb-node-selected .iwb-node-title { opacity: 1; font-weight: 600; } /* 头部操作按钮继续隐藏:其功能在气泡 / 右键菜单中已有,显示后会与气泡重复。 */ .iwb-node-head .iwb-node-headbtns { display: none; } @@ -203,7 +249,7 @@ button { font-family: inherit; } .iwb-node-floatbar button.iwb-fb-del:hover { color: var(--iwb-err); background: color-mix(in srgb, var(--iwb-err) 12%, transparent); } .iwb-node-headbtns { display: flex; gap: 2px; } .iwb-node-del { background: none; border: none; color: var(--iwb-text2); cursor: pointer; font-size: 12px; padding: 0 3px; display: inline-flex; align-items: center; justify-content: center; } -.iwb-node-del:hover { color: var(--iwb-brand); } +.iwb-node-del:hover { color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-node-body { padding: 8px 10px; overflow: visible; flex: 1 1 auto; min-height: 0; } /* 插件自定义节点体容器(2026-11-14):宿主只提供一块稳定画布(防 React 重建导致输入框失焦), 内部排版(缩略图 / 变量行 / 开关)全由插件自己的 CSS 决定,这里不给内边距也不预设布局。 */ @@ -276,7 +322,7 @@ button { font-family: inherit; } .iwb-ref-img { flex: 1; max-height: 90px; object-fit: contain; border-radius: 6px; border: 1px solid var(--iwb-border); background: var(--iwb-layer2); cursor: move; min-width: 0; } .iwb-ref-imgactions { flex: 0 0 auto; display: flex; flex-direction: column; gap: 2px; } .iwb-file { display: inline-block; margin-top: 6px; padding: 4px 10px; border: 1px dashed var(--iwb-border2); border-radius: 6px; font-size: 12px; cursor: pointer; color: var(--iwb-text2); } -.iwb-file:hover { border-color: var(--iwb-brand); color: var(--iwb-brand); } +.iwb-file:hover { border-color: var(--iwb-brand); color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-hint { font-size: 10px; color: var(--iwb-text2); margin-top: 4px; } .iwb-results { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; } .iwb-rgroup { width: 100%; } @@ -454,7 +500,7 @@ button { font-family: inherit; } .iwb-picktext { color: var(--iwb-text); line-height: 1.4; word-break: break-all; } .iwb-ref-upload { flex: 1 1 auto; min-height: 110px; display: flex; align-items: center; justify-content: center; border: 1.5px dashed var(--iwb-border2); border-radius: 8px; color: var(--iwb-text2); font-size: 13px; cursor: move; } -.iwb-ref-upload:hover { border-color: var(--iwb-brand); color: var(--iwb-brand); } +.iwb-ref-upload:hover { border-color: var(--iwb-brand); color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-ref-emptybox { flex: 1 1 auto; min-height: 110px; display: flex; flex-direction: column; gap: 6px; } .iwb-ref-url-row { display: flex; gap: 5px; align-items: center; } .iwb-ref-url-row .iwb-ref-upload-link { background: var(--iwb-layer); border-color: var(--iwb-border); color: var(--iwb-text2); } @@ -485,7 +531,7 @@ button { font-family: inherit; } .iwb-speed { border: 1px solid var(--iwb-border); border-radius: 8px; padding: 6px 8px; margin: 6px 0; background: var(--iwb-layer); } .iwb-speed-row { display: flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 11px; } .iwb-speed-ms { flex: 0 0 74px; font-weight: 600; } -.iwb-speed-fast { color: var(--iwb-brand); } +.iwb-speed-fast { color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-speed-url { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--iwb-text2); } .iwb-modellist { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 6px 0; } .iwb-modelrow { padding: 2px 8px; border: 1px solid var(--iwb-border); border-radius: 6px; background: var(--iwb-layer); } @@ -540,7 +586,7 @@ button { font-family: inherit; } .iwb-history-more { text-align: center; padding: 6px 0; } .iwb-help { gap: 10px; } .iwb-help-row { font-size: 14px; line-height: 1.6; } -.iwb-help-row b { color: var(--iwb-brand); font-weight: 700; margin-right: 6px; } +.iwb-help-row b { color: var(--iwb-brand-text, var(--iwb-brand)); font-weight: 700; margin-right: 6px; } /* 设置面板:字号 +2、间距加大,方便阅读 */ .iwb-settings-modal .iwb-modal-head { padding: 14px 20px; } .iwb-settings-modal .iwb-modal-body { font-size: 14px; gap: 16px; padding: 18px 22px; } @@ -558,7 +604,7 @@ button { font-family: inherit; } .iwb-backup-embedded .iwb-modal-body { display: flex; flex-direction: column; gap: 14px; padding: 0; } .iwb-backup-modal .iwb-modal-body { font-size: 14px; gap: 14px; } .iwb-backup-sec { display: flex; flex-direction: column; gap: 7px; padding: 10px 12px; border: 1px solid var(--iwb-border); border-radius: 10px; background: color-mix(in srgb, var(--iwb-layer) 30%, transparent); } -.iwb-backup-sec-title { font-weight: 700; color: var(--iwb-brand); font-size: 13px; } +.iwb-backup-sec-title { font-weight: 700; color: var(--iwb-brand-text, var(--iwb-brand)); font-size: 13px; } .iwb-backup-item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; padding: 2px 0; } .iwb-backup-item input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--iwb-brand); cursor: pointer; } .iwb-backup-item-name { flex: 0 0 auto; } @@ -593,14 +639,14 @@ button { font-family: inherit; } /* ---- v3:左侧多工作台 ---- */ .iwb-wsrail { position: absolute; left: 0; top: 36px; bottom: 0; width: 52px; background: var(--iwb-panel); border-right: 1px solid var(--iwb-border); z-index: 25; display: flex; flex-direction: column; align-items: stretch; transition: width 0.15s; } .iwb-wsrail-title { align-items: center; gap: 4px; padding: 14px 12px; font-weight: 800; font-size: 18px; color: var(--iwb-text); border-bottom: 1px solid var(--iwb-border); cursor: default; user-select: none; white-space: nowrap; flex: 0 0 auto; justify-content: center; } -.iwb-wsrail-title:hover { background: var(--iwb-layer); } +.iwb-wsrail-title:hover { background: var(--iwb-hover); } /* 展开态标题行右侧 ⋯ 三点菜单(Portal 挂 body + fixed 定位:右侧展开不切割、层级高于画布) */ .iwb-wsrail-title-more-wrap { position: relative; margin-left: auto; display: inline-flex; align-items: center; } .iwb-ws-title-more { flex: 0 0 24px; width: 24px; height: 24px; padding: 0; } -.iwb-ws-more { position: fixed; z-index: 310; min-width: 210px; padding: 6px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.16); display: flex; flex-direction: column; gap: 2px; } +.iwb-ws-more { position: fixed; z-index: 310; min-width: 210px; padding: 6px; background: var(--iwb-bg-menu); border: 1px solid var(--iwb-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.16); display: flex; flex-direction: column; gap: 2px; } .iwb-ws-more .iwb-ctx-item { white-space: nowrap; } .iwb-ws-more-ver { font-size: 11px; color: var(--iwb-text2); padding: 4px 10px 2px; user-select: none; } -.iwb-wsrail-title-more .iwb-ws-title-more { color: var(--iwb-brand); } +.iwb-wsrail-title-more .iwb-ws-title-more { color: var(--iwb-brand-text, var(--iwb-brand)); } /* 展开状态下顶部标题字号翻倍(含内部文字 span,覆盖 .iwb-btn-text 固定 12px) */ .ws-expanded .iwb-wsrail-title { font-size: 18px; } .ws-expanded .iwb-wsrail-title .iwb-btn-text { font-size: inherit; } @@ -613,7 +659,7 @@ button { font-family: inherit; } /* 页面加载动画:logo 弹跳 + 进度条光斑 + 淡出 */ .iwb-splash { position: fixed; inset: 0; z-index: 400; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: var(--iwb-bg); transition: opacity 0.5s ease; } .iwb-splash-fade { opacity: 0; pointer-events: none; } -.iwb-splash-logo { width: 54px; height: 54px; color: var(--iwb-brand); animation: iwb-splash-bounce 1.2s ease-in-out infinite; } +.iwb-splash-logo { width: 54px; height: 54px; color: var(--iwb-brand-text, var(--iwb-brand)); animation: iwb-splash-bounce 1.2s ease-in-out infinite; } .iwb-splash-title { font-size: 18px; font-weight: 700; color: var(--iwb-text); letter-spacing: 1px; } .iwb-splash-sub { font-size: 12px; color: var(--iwb-text2); } .iwb-splash-bar { width: 240px; height: 5px; border-radius: 3px; background: var(--iwb-layer); overflow: hidden; position: relative; border: 1px solid var(--iwb-border); } @@ -657,10 +703,10 @@ button { font-family: inherit; } .iwb-drawer-tabs { display: flex; align-items: center; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--iwb-border); flex: 0 0 auto; } .iwb-drawer-tab { background: none; border: 1px solid transparent; border-radius: 8px; padding: 5px 10px; font-size: 12px; color: var(--iwb-text2); cursor: pointer; white-space: nowrap; } .iwb-drawer-tab:hover { color: var(--iwb-text); } -.iwb-drawer-tab-active { background: var(--iwb-layer); border-color: var(--iwb-border); color: var(--iwb-brand); font-weight: 700; } +.iwb-drawer-tab-active { background: var(--iwb-layer); border-color: var(--iwb-border); color: var(--iwb-brand-text, var(--iwb-brand)); font-weight: 700; } .iwb-drawer-body { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; } .iwb-drawer-toggle { position: absolute; right: 0; top: 50%; transform: translateY(-50%); z-index: 21; background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-right: none; border-radius: 8px 0 0 8px; padding: 12px 5px; cursor: pointer; font-size: 12px; color: var(--iwb-text2); box-shadow: -4px 0 12px rgba(0,0,0,0.1); letter-spacing: 2px; } -.iwb-drawer-toggle:hover { color: var(--iwb-brand); } +.iwb-drawer-toggle:hover { color: var(--iwb-brand-text, var(--iwb-brand)); } /* 嵌入抽屉时面板填满 */ .iwb-lib-embedded, .iwb-groups-embedded { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; } /* 节点组卡片:删除按钮默认隐藏,悬停卡片时显示 */ @@ -757,9 +803,15 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s cursor: pointer; transition: border-color var(--tr-fast), background var(--tr-fast), color var(--tr-fast), box-shadow var(--tr-fast); } -.iwb-btn:hover { border-color: var(--iwb-brand); color: var(--iwb-brand); } +.iwb-btn:hover { border-color: var(--iwb-brand); color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-btn:active { transform: translateY(1px); } -.iwb-btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--iwb-brand) 60%, transparent); outline-offset: 1px; } +.iwb-btn:focus-visible { outline: var(--iwb-focus-ring); outline-offset: 2px; } +/* D8 补齐:菜单项 / 右键菜单项 / 停靠栏按钮 / 下拉,此前用鼠标没问题、纯键盘走查全靠猜 */ +.iwb-ctx-item:focus-visible, +.iwb-home-menu-item:focus-visible, +.iwb-dock-btn:focus-visible, +.iwb-nav-item:focus-visible, +.iwb-wsrail-title:focus-visible { outline: var(--iwb-focus-ring); outline-offset: -2px; } .iwb-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; } .iwb-btn-primary { background: var(--iwb-brand); border-color: var(--iwb-brand); color: var(--iwb-on-brand); } .iwb-btn-primary:hover { background: color-mix(in srgb, var(--iwb-brand) 85%, #000); border-color: var(--iwb-brand); color: var(--iwb-on-brand); } @@ -812,7 +864,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* ---- 右侧竖向面板栏(与左侧栏统一:无阴影) ---- */ .iwb-rightrail { position: absolute; right: 0; top: 0; bottom: 0; width: 48px; background: transparent; z-index: 24; display: flex; flex-direction: column; align-items: center; padding: 12px 4px; gap: 8px; } .iwb-rail-tab { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 40px; padding: 9px 2px; border-radius: 8px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); color: var(--iwb-text2); font-size: 12px; cursor: pointer; } -.iwb-rail-tab:hover { border-color: var(--iwb-brand); color: var(--iwb-brand); } +.iwb-rail-tab:hover { border-color: var(--iwb-brand); color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-rail-tab-active { border-color: var(--iwb-brand); background: color-mix(in srgb, var(--iwb-brand) 14%, transparent); color: var(--iwb-text); font-weight: 700; } .iwb-rail-tab .iwb-ic { width: 16px; height: 16px; } .iwb-rail-tab .iwb-btn-text { writing-mode: vertical-rl; font-size: 11px; letter-spacing: 2px; } @@ -822,7 +874,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-ws-headicon { flex: 0 0 26px; width: 26px; height: 24px; padding: 0; justify-content: center; background: transparent !important; border: none !important; color: var(--iwb-text2); opacity: 0.75; transition: opacity 0.12s, color 0.12s; } .iwb-ws-headicon:hover { opacity: 1; color: var(--iwb-text); } .iwb-ws-headicon:active { opacity: 1; color: var(--iwb-text); } -.iwb-ws-headicon.iwb-btn-primary { background: transparent !important; border: none !important; color: var(--iwb-brand); opacity: 1; } +.iwb-ws-headicon.iwb-btn-primary { background: transparent !important; border: none !important; color: var(--iwb-brand-text, var(--iwb-brand)); opacity: 1; } .iwb-ws-headicon .iwb-ic { width: 14px; height: 14px; } .iwb-toolbar-bottom .iwb-btn-fit .iwb-ic { width: 15px; height: 15px; } @@ -835,12 +887,12 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-command-mask { position: fixed; inset: 0; z-index: 120; display: flex; justify-content: center; align-items: flex-start; padding-top: 13vh; background: rgba(10, 12, 18, 0.32); } .iwb-command { width: min(560px, calc(100vw - 32px)); max-height: min(560px, 72vh); overflow: hidden; background: var(--iwb-panel); border: 1px solid var(--iwb-border2); border-radius: 12px; box-shadow: 0 18px 60px rgba(0,0,0,.32); display: flex; flex-direction: column; } .iwb-command-head { display: flex; align-items: center; gap: 9px; padding: 12px 14px; border-bottom: 1px solid var(--iwb-border); } -.iwb-command-icon { color: var(--iwb-brand); font-size: 11px; font-weight: 800; } +.iwb-command-icon { color: var(--iwb-brand-text, var(--iwb-brand)); font-size: 11px; font-weight: 800; } .iwb-command-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--iwb-text); font-size: 14px; } .iwb-command-list { overflow-y: auto; padding: 6px; } .iwb-command-item { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--iwb-text); text-align: left; cursor: pointer; font-size: 13px; } -.iwb-command-item:hover, .iwb-command-item:focus { outline: 0; background: var(--iwb-layer2); color: var(--iwb-brand); } -.iwb-command-item-active { outline: 0; background: var(--iwb-layer2); color: var(--iwb-brand); } +.iwb-command-item:hover, .iwb-command-item:focus { outline: 0; background: var(--iwb-layer2); color: var(--iwb-brand-text, var(--iwb-brand)); } +.iwb-command-item-active { outline: 0; background: var(--iwb-layer2); color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-command-item .iwb-ic { width: 16px; height: 16px; flex: 0 0 auto; } .iwb-command-empty { padding: 22px 12px; text-align: center; color: var(--iwb-text2); font-size: 12px; } .iwb-command-foot { padding: 8px 14px; border-top: 1px solid var(--iwb-border); color: var(--iwb-text2); font-size: 11px; } @@ -883,14 +935,14 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* ---- 自定义右键菜单 ---- */ .iwb-ctxmask { position: fixed; inset: 0; background: transparent; z-index: 90; } -.iwb-ctxmenu { position: fixed; min-width: 196px; max-width: 240px; max-height: calc(100vh - 24px); overflow-y: auto; padding: 6px; background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.16); z-index: 91; display: flex; flex-direction: column; gap: 2px; } +.iwb-ctxmenu { position: fixed; min-width: 196px; max-width: 240px; max-height: calc(100vh - 24px); overflow-y: auto; padding: 6px; background: var(--iwb-bg-menu); border: 1px solid var(--iwb-border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.16); z-index: 91; display: flex; flex-direction: column; gap: 2px; } /* 提示词/节点组的右键「移动到分组」菜单已 portal 到 body:需高于 .iwb-overlay(z-index:100),否则被应用层盖住 */ .iwb-ctxmenu.iwb-lib-group-menu { z-index: 270; /* 高于资源中心全窗口(.iwb-fullmask 260)、低于弹窗(300):修复提示词/节点组右键菜单被资源库窗口盖住 */ } .iwb-ctx-title { font-size: 10px; font-weight: 700; color: var(--iwb-text2); letter-spacing: 1px; padding: 6px 10px 2px; text-transform: uppercase; } .iwb-ctx-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: none; border-radius: 8px; background: transparent; color: var(--iwb-text); font-size: 12.5px; cursor: pointer; text-align: left; } .iwb-ctx-item .iwb-ic { width: 14px; height: 14px; flex: 0 0 auto; color: var(--iwb-text2); } .iwb-ctx-item:hover:not(:disabled) { background: color-mix(in srgb, var(--iwb-brand) 12%, transparent); color: var(--iwb-text); } -.iwb-ctx-item:hover:not(:disabled) .iwb-ic { color: var(--iwb-brand); } +.iwb-ctx-item:hover:not(:disabled) .iwb-ic { color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-ctx-item:disabled { opacity: 0.38; cursor: default; } .iwb-ctx-item.iwb-ctx-danger { color: var(--iwb-err); } .iwb-ctx-item.iwb-ctx-danger .iwb-ic { color: var(--iwb-err); } @@ -939,7 +991,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-task-inactive { opacity: 0.55; border-left-color: var(--iwb-border2); } .iwb-task-inactive .iwb-task-title { text-decoration: line-through; } .iwb-task { position: relative; overflow: hidden; } -.iwb-task-refinfo { font-size: 10px; font-weight: 400; color: #8a93a6; margin-left: 3px; white-space: nowrap; } +.iwb-task-refinfo { font-size: 10px; font-weight: 400; color: var(--iwb-text-dim); margin-left: 3px; white-space: nowrap; } .iwb-generation-spinner { position: relative; z-index: 2; display: inline-block; width: 12px; height: 12px; flex: 0 0 12px; border: 2px solid var(--iwb-anim-track); border-top-color: var(--iwb-anim); border-right-color: var(--iwb-anim); border-radius: 50%; animation: iwb-generation-spinner-spin 0.9s linear infinite; } .iwb-task-count-sel { min-width: 56px; border: none; background-color: transparent; background-image: url("data:image/svg+xml;utf8,"); background-repeat: no-repeat; background-position: right 3px center; appearance: none; -webkit-appearance: none; -moz-appearance: none; } @keyframes iwb-generation-spinner-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @@ -984,14 +1036,14 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-combine-srcs { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; } .iwb-combine-src { font-size: 11px; color: var(--iwb-text2); background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 6px; padding: 3px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* 组合来源行里的「样式名」标签(2026-11-14):只给插件提示词类节点打标,帮用户认出这一行来自哪条风格 */ -.iwb-combine-src-tag { display: inline-block; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; margin-right: 4px; padding: 0 5px; border-radius: 4px; background: color-mix(in srgb, var(--iwb-brand) 16%, transparent); color: var(--iwb-brand); font-size: 10px; line-height: 15px; } +.iwb-combine-src-tag { display: inline-block; max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; margin-right: 4px; padding: 0 5px; border-radius: 4px; background: color-mix(in srgb, var(--iwb-brand) 16%, transparent); color: var(--iwb-brand-text, var(--iwb-brand)); font-size: 10px; line-height: 15px; } .iwb-batch-srcs { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; } .iwb-batch-src { font-size: 11px; color: var(--iwb-text2); background: var(--iwb-layer); border: 1px solid var(--iwb-border); border-radius: 6px; padding: 3px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .iwb-combine-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; } .iwb-combine-row .iwb-plabel { flex: 0 0 48px; font-size: 11px; color: var(--iwb-text2); } .iwb-combine-row .iwb-input { flex: 1 1 auto; font-size: 11px; padding: 3px 5px; } .iwb-combine-out { margin-top: 6px; border: 1px solid color-mix(in srgb, var(--iwb-brand) 35%, transparent); border-radius: 7px; background: color-mix(in srgb, var(--iwb-brand) 8%, transparent); padding: 6px 8px; } -.iwb-combine-out-label { font-size: 10px; font-weight: 700; color: var(--iwb-brand); margin-bottom: 3px; } +.iwb-combine-out-label { font-size: 10px; font-weight: 700; color: var(--iwb-brand-text, var(--iwb-brand)); margin-bottom: 3px; } .iwb-combine-out-text { font-size: 11px; color: var(--iwb-text); white-space: pre-wrap; word-break: break-all; max-height: 90px; overflow-y: auto; } /* 输出节点:田字格/瀑布流 + 批量下载 */ @@ -1010,7 +1062,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-out-cell-actions { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; display: flex; align-items: center; justify-content: center; gap: 10px; opacity: 0; transition: opacity 0.15s; border-radius: 0 0 8px 8px; background: rgba(0,0,0,0.45); } .iwb-out-cell:hover .iwb-out-cell-actions { opacity: 1; } .iwb-out-cell-actions .iwb-btn { width: 18px; height: 18px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(255,255,255,0.9); color: #333; border: none; cursor: pointer; } -.iwb-out-cell-actions .iwb-btn:hover { background: var(--iwb-panel); color: var(--iwb-brand); } +.iwb-out-cell-actions .iwb-btn:hover { background: var(--iwb-panel); color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-out-cell-actions .iwb-ic { width: 11px; height: 11px; } /* 输出节点:原比例自适应流式(组内横向排列,随节点宽度自动换行) */ @@ -1107,7 +1159,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-oplogs { max-height: 180px; overflow-y: auto; border: 1px solid var(--iwb-border); border-radius: 8px; padding: 6px 8px; display: flex; flex-direction: column; gap: 3px; background: var(--iwb-layer); } .iwb-oplog { display: flex; gap: 8px; font-size: 11.5px; line-height: 1.5; } .iwb-oplog-time { flex: 0 0 auto; color: var(--iwb-text2); font-variant-numeric: tabular-nums; } -.iwb-oplog-kind { flex: 0 0 44px; color: var(--iwb-brand); font-weight: 700; } +.iwb-oplog-kind { flex: 0 0 44px; color: var(--iwb-brand-text, var(--iwb-brand)); font-weight: 700; } .iwb-oplog-msg { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } @@ -1132,7 +1184,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-home-sec-head:first-child { border-top: none; padding-top: 0; } .iwb-home-card span { color: var(--iwb-text2); font-size: 12px; } -.iwb-home-new { align-items: center; justify-content: center; color: var(--iwb-brand); } +.iwb-home-new { align-items: center; justify-content: center; color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-canvas-hidden { visibility: hidden; pointer-events: none; } .iwb-shell-nav { position: static; flex-direction: column; gap: 3px; padding: 8px; border: 0; border-bottom: 1px solid var(--iwb-border); border-radius: 0; background: transparent; box-shadow: none; } .iwb-shell-nav-item { width: 100%; justify-content: flex-start; min-height: 34px; } @@ -1276,7 +1328,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-canvas-meta { display: flex; align-items: center; gap: 8px; overflow: hidden; } .iwb-canvas-meta .iwb-status-item { font-size: 11px; color: var(--iwb-text2); white-space: nowrap; } -.iwb-canvas-meta .iwb-status-ok { color: var(--iwb-brand); } +.iwb-canvas-meta .iwb-status-ok { color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-canvas-meta .iwb-status-err { color: var(--iwb-err); } .iwb-canvas-topbar .iwb-top-nav-icon { width: 30px; height: 30px; } /* S12:顶部标签条(浏览器式多画布标签)——UX_SPEC §4 单框扁平 token(容器透明、active 品牌色扁平高亮、只用 CSS 变量) */ @@ -1287,8 +1339,8 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-tab:hover { background: var(--iwb-layer2); color: var(--iwb-text); } .iwb-tab-active { background: color-mix(in srgb, var(--iwb-tint) 9%, transparent); color: var(--iwb-text); font-weight: 600; } /* 暗色下标签条本身是中灰:用「近黑 9%」叠上去几乎看不出选中 ⇒ 改为**提亮**一档(2026-11-01 用户反馈) */ -.theme-dark .iwb-tabstrip .iwb-tab-active { background: color-mix(in srgb, #ffffff 22%, transparent); color: var(--iwb-text); } -.iwb-tab:focus-visible { outline: 2px solid color-mix(in srgb, var(--iwb-tint) 35%, transparent); outline-offset: 1px; } +.theme-dark .iwb-tabstrip .iwb-tab-active { background: var(--iwb-hover); } +.iwb-tab:focus-visible { outline: var(--iwb-focus-ring); outline-offset: 1px; } /* 首页激活胶囊走灰阶(首页整体灰色系;画布标签仍用品牌色) */ .iwb-tab-home.iwb-tab-active { background: transparent; color: var(--iwb-text); } /* 首页图标与画布标签之间的细分隔线 */ @@ -1299,7 +1351,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-tab-dot-ok { background: var(--iwb-ok); } .iwb-tab-dot-err { background: var(--iwb-err); } .iwb-tab-new { color: var(--iwb-text2); font-weight: 700; padding: 0 10px; font-size: 15px; line-height: 1; } -.iwb-tab-new:hover { background: color-mix(in srgb, var(--iwb-brand) 12%, transparent); color: var(--iwb-brand); } +.iwb-tab-new:hover { background: color-mix(in srgb, var(--iwb-brand) 12%, transparent); color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-tab-close { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; margin-left: 31px; /* 与标签名留约 3 个字的间距(gap 5px + 31px ≈ 36px) */ border: 0; border-radius: 4px; background: transparent; color: var(--iwb-text2); cursor: pointer; opacity: 0; transition: opacity .12s; padding: 0; } .iwb-tab:hover .iwb-tab-close { opacity: 1; } .iwb-tab-close:hover { background: color-mix(in srgb, var(--iwb-text2) 16%, transparent); color: var(--iwb-text); } @@ -1313,7 +1365,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* 资源中心浮动窗口:自由拖动、统一白色圆角样式 */ .iwb-resource-float { position: fixed; z-index: 46; width: 360px; max-height: 76vh; display: flex; flex-direction: column; background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: 12px; box-shadow: 0 16px 48px rgba(0,0,0,.24), 0 2px 10px rgba(0,0,0,.12); overflow: hidden; } .iwb-resource-float-head { display: flex; align-items: center; gap: 6px; padding: 9px 12px; background: var(--iwb-layer2); border-bottom: 1px solid var(--iwb-border); cursor: move; user-select: none; flex: 0 0 auto; } -.iwb-resource-float-head:hover { background: var(--iwb-layer); } +.iwb-resource-float-head:hover { background: var(--iwb-hover); } .iwb-resource-float-title { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 12.5px; color: var(--iwb-text); } .iwb-resource-float-title .iwb-ic { width: 15px; height: 15px; } .iwb-resource-float-spacer { flex: 1 1 auto; } @@ -1395,7 +1447,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-home-side-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--iwb-text2); font-size: 14px; cursor: pointer; text-align: left; box-sizing: border-box; } .iwb-home-side-item .iwb-ic { color: var(--iwb-text2); } .iwb-home-side-item:hover { background: color-mix(in srgb, var(--iwb-panel) 45%, transparent); color: var(--iwb-text); } -.iwb-home-side-item:focus-visible { outline: 2px solid color-mix(in srgb, var(--iwb-tint) 30%, transparent); outline-offset: -2px; } +.iwb-home-side-item:focus-visible { outline: var(--iwb-focus-ring); outline-offset: -2px; } .iwb-home-side-item.active { background: color-mix(in srgb, var(--iwb-panel) 32%, transparent); color: var(--iwb-text); font-weight: 600; } .iwb-home-side-item.active .iwb-ic { color: var(--iwb-text); } .iwb-home-side-item.iwb-home-side-add { color: var(--iwb-text); font-size: 13px; } @@ -1470,7 +1522,10 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s min-width: 0; min-height: 138px; overflow: hidden; - background: color-mix(in srgb, var(--iwb-panel) 52%, var(--iwb-home-bg) 48%); + /* 卡片用「浮起层」底色(与右键菜单同一档):亮色=面板色,暗色比面板亮一档。 + 任何基于 panel/homeBg 的百分比混合在暗色下都拉不开 —— 两者只差 6, + 52/48 算出 #191919、80/20 算出 #1b1b1b,都跟首页底 #161616 几乎同色,卡片等于隐形。 */ + background: var(--iwb-bg-menu); border: 1px solid var(--iwb-border); border-radius: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.05); @@ -1519,34 +1574,20 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-canvas-topbar button:not(.iwb-canvas-title), .iwb-canvas-topbar input, .iwb-canvas-topbar label { pointer-events: auto; } .iwb-canvas-title { pointer-events: auto; } .iwb-canvas, .ws-expanded .iwb-canvas { top: 0 !important; } -/* 灰色主题:顶栏文字/图标改亮灰,透明悬浮在深画布上更清晰 */ -.theme-dark .iwb-canvas-topbar .iwb-canvas-title, -.theme-dark .iwb-canvas-topbar .iwb-canvas-meta .iwb-status-item, -.theme-dark .iwb-canvas-topbar .iwb-top-nav-icon, -.theme-dark .iwb-canvas-topbar .iwb-canvas-back, -.theme-dark .iwb-product-nav .iwb-product-brand, -.theme-dark .iwb-product-nav .iwb-product-icon, -.theme-dark .iwb-product-nav .iwb-product-item { color: #e0e0e0; } -/* hover/active:高亮底是浅色,文字回深色保证可读 */ -.theme-dark .iwb-canvas-topbar .iwb-top-nav-icon:hover, -.theme-dark .iwb-canvas-topbar .iwb-top-nav-icon-active, -.theme-dark .iwb-canvas-topbar .iwb-canvas-title:hover, -.theme-dark .iwb-product-nav .iwb-product-icon:hover, -.theme-dark .iwb-product-nav .iwb-product-item:hover, -.theme-dark .iwb-product-nav .iwb-product-item.active { color: #1a1a1a; } -.theme-dark .iwb-canvas-topbar .iwb-top-nav-icon:hover, -.theme-dark .iwb-product-nav .iwb-product-icon:hover, -.theme-dark .iwb-product-nav .iwb-product-item:hover { background: rgba(255,255,255,0.5); } -/* 顶栏内输入框(重命名标题)保持深色文字,避免被顶栏亮灰覆盖看不清 */ -.theme-dark .iwb-canvas-topbar .iwb-input { color: #111; } -/* 状态错误:灰底上保留红色可辨识 */ -.theme-dark .iwb-canvas-meta .iwb-status-err { color: #ff5f5f; } -/* 任务后的张数说明(1 张参考图):灰底上改深色可读 */ -.theme-dark .iwb-task-refinfo { color: #1a1a1a; } +/* 顶栏是 transparent 悬浮在画布上(见 .iwb-canvas-topbar 的 background: transparent !important), + 文字直接吃 --iwb-text —— 它对 --iwb-canvas-bg 已按 7:1 派生,亮暗两套都不需要专门补丁。 + v3.26.44 之前这里有 6 组「#e0e0e0 / #1a1a1a / rgba(255,255,255,.5)」硬编码, + 全部针对旧的「中灰底 + 深字」暗色设计,在新派生色下只会让 hover 变成刺眼白块。 */ +.iwb-canvas-topbar .iwb-top-nav-icon:hover, +.iwb-canvas-topbar .iwb-top-nav-icon-active, +.iwb-canvas-topbar .iwb-canvas-title:hover, +.iwb-product-nav .iwb-product-icon:hover, +.iwb-product-nav .iwb-product-item:hover, +.iwb-product-nav .iwb-product-item.active { background: color-mix(in srgb, var(--iwb-text) 12%, transparent); } /* 任务级计时(等宽数字避免抖动) */ .iwb-task-timer { flex: 0 0 auto; font-size: 11px; font-weight: 700; color: var(--iwb-text2); white-space: nowrap; font-variant-numeric: tabular-nums; margin-right: 2px; } -.iwb-task-timer-run { color: var(--iwb-brand); } +.iwb-task-timer-run { color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-task-timer-done { color: var(--iwb-text2); } /* 运行中的任务(v3.24.42 重做):去掉左侧竖条与底部进度线,改为两层克制的动效—— * ① 一次性扫光(::before,1.05s 掠过):任务「刚开始」时的一道淡白光,只跑一次,不循环打扰; @@ -1662,7 +1703,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* 纯描边胶囊:与截图一致(选中只加重描边与文字色,不填充) */ .iwb-chip-line { background: transparent; border: 1px solid var(--iwb-border); color: var(--iwb-text); border-radius: 999px; padding: 5px 14px; } .iwb-chip-line:hover { border-color: var(--iwb-brand); color: var(--iwb-text); } -.iwb-chip-line-on, .iwb-chip-line-on:hover { background: transparent; border-color: var(--iwb-brand); color: var(--iwb-brand); font-weight: 700; } +.iwb-chip-line-on, .iwb-chip-line-on:hover { background: transparent; border-color: var(--iwb-brand); color: var(--iwb-brand-text, var(--iwb-brand)); font-weight: 700; } .iwb-pop-anchor .iwb-setcell { background: var(--iwb-panel); } /* 节点内图像设置汇总条(唯一入口,点击弹出面板) */ .iwb-gen-summary { align-self: flex-start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; } @@ -1697,7 +1738,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* 与「尺寸」汇总条保持同一左右内边距(实测原来 12 vs 14 不统一) */ padding: 6px 14px; line-height: 1.2; } -.iwb-gen-settings .iwb-pick:hover { border-color: var(--iwb-brand); color: var(--iwb-brand); } +.iwb-gen-settings .iwb-pick:hover { border-color: var(--iwb-brand); color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-gen-settings .iwb-pick:disabled { opacity: 0.45; cursor: not-allowed; transform: none; } .iwb-gen-summary { font-size: 15px; padding: 6px 14px; } @@ -1777,7 +1818,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-quality-toggle input { appearance: none; -webkit-appearance: none; width: 12px; height: 12px; border: 1px solid currentColor; border-radius: 3px; margin: 0; position: relative; } .iwb-quality-toggle input:checked::after { content: ''; position: absolute; inset: 2px; background: currentColor; border-radius: 1px; } .iwb-quality-toggle:hover { border-color: var(--iwb-brand); } -.iwb-quality-toggle.on { border-color: var(--iwb-brand); color: var(--iwb-brand); font-weight: 600; background: color-mix(in srgb, var(--iwb-brand) 12%, transparent); } +.iwb-quality-toggle.on { border-color: var(--iwb-brand); color: var(--iwb-brand-text, var(--iwb-brand)); font-weight: 600; background: color-mix(in srgb, var(--iwb-brand) 12%, transparent); } .iwb-shape-hint { flex: 1 1 100%; margin-top: 2px; } /* v3.87.39 顶部状态栏:加半透明白底 + 背景模糊,避免叠在图片/内容上时文字看不清 */ @@ -1903,7 +1944,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-prompt-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; padding: 10px 14px; overflow-x: auto; } .iwb-prompt-tool { height: 30px; min-width: 30px; padding: 0 8px; border: 0; background: transparent; color: var(--iwb-text2); border-radius: 8px; cursor: pointer; font: inherit; font-size: 13px; flex: 0 0 auto; white-space: nowrap; } -.iwb-prompt-tool:hover { background: var(--iwb-layer); color: var(--iwb-text); } +.iwb-prompt-tool:hover { background: var(--iwb-hover); color: var(--iwb-text); } .iwb-prompt-bar-sp { flex: 1 1 auto; } /* 组间分隔:格式按钮分组(标题 / 块级 / 行内 / 清除)+ 复制,视觉上不再糊成一排 */ .iwb-prompt-sep { flex: 0 0 auto; width: 1px; height: 16px; margin: 0 6px; background: var(--iwb-border); } @@ -1968,8 +2009,8 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-gc-grid { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; overflow: auto; max-height: 48vh; padding-right: 2px; } .iwb-gc-item { flex: 0 0 auto; width: auto; min-width: max-content; max-width: 100%; display: flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid var(--iwb-border); border-radius: 10px; background: var(--iwb-panel); color: var(--iwb-text); font-size: 13px; cursor: pointer; white-space: nowrap; text-align: left; } .iwb-gc-name { white-space: nowrap; } -.iwb-gc-tick { margin-left: auto; color: var(--iwb-brand); font-weight: 700; } -.iwb-gc-item:hover { border-color: var(--iwb-brand); color: var(--iwb-brand); } +.iwb-gc-tick { margin-left: auto; color: var(--iwb-brand-text, var(--iwb-brand)); font-weight: 700; } +.iwb-gc-item:hover { border-color: var(--iwb-brand); color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-gc-item-on { border-color: var(--iwb-brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--iwb-brand) 18%, transparent); } .iwb-gc-item-err { border-color: var(--iwb-err); color: var(--iwb-err); } .iwb-gc-empty { font-size: 12px; color: var(--iwb-text2); padding: 6px 2px; } @@ -1993,11 +2034,11 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s * 现在自己没写字时直接把上游文本显示出来(.is-inherited 只改字色,零布局位移), * 状态条说明「继承 / 已固定」并给出「恢复跟随」。 */ .iwb-inherit-bar { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-size: 10.5px; line-height: 16px; color: var(--iwb-text2); min-width: 0; } -.iwb-inherit-tag { flex: 0 0 auto; padding: 0 5px; border-radius: 999px; font-size: 10px; color: var(--iwb-brand); background: color-mix(in srgb, var(--iwb-brand) 12%, transparent); } +.iwb-inherit-tag { flex: 0 0 auto; padding: 0 5px; border-radius: 999px; font-size: 10px; color: var(--iwb-brand-text, var(--iwb-brand)); background: color-mix(in srgb, var(--iwb-brand) 12%, transparent); } .iwb-inherit-tag.is-taken { color: var(--iwb-text); background: color-mix(in srgb, var(--iwb-tint) 10%, transparent); } .iwb-inherit-src { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .iwb-inherit-more { flex: 0 0 auto; opacity: .78; } -.iwb-inherit-reset { flex: 0 0 auto; border: 0; background: transparent; padding: 0; font: inherit; color: var(--iwb-brand); cursor: pointer; } +.iwb-inherit-reset { flex: 0 0 auto; border: 0; background: transparent; padding: 0; font: inherit; color: var(--iwb-brand-text, var(--iwb-brand)); cursor: pointer; } .iwb-inherit-reset:hover { color: var(--iwb-text); text-decoration: underline; } .iwb-textarea.is-inherited { color: color-mix(in srgb, var(--iwb-text) 74%, transparent); } @@ -2019,7 +2060,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-plugin-desc { color: var(--iwb-text2); font-size: 13px; line-height: 1.5; margin-top: 2px; } /* 页内确认框(替代原生 confirm,避免 WKWebView 主线程阻塞) */ .iwb-confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.38); display: flex; align-items: center; justify-content: center; z-index: 9999; } -.iwb-confirm-box { width: min(460px, calc(100vw - 48px)); background: var(--iwb-layer); color: var(--iwb-text); border-radius: 12px; padding: 18px 20px 14px; box-shadow: 0 12px 40px rgba(0,0,0,.28); } +.iwb-confirm-box { width: min(460px, calc(100vw - 48px)); background: var(--iwb-bg-menu); color: var(--iwb-text); border-radius: 12px; padding: 18px 20px 14px; box-shadow: 0 12px 40px rgba(0,0,0,.28); } .iwb-confirm-title { font-weight: 650; font-size: 15px; margin-bottom: 8px; } .iwb-confirm-text { font-size: 13.5px; line-height: 1.65; color: var(--iwb-text2); white-space: pre-wrap; word-break: break-word; } .iwb-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; } @@ -2144,7 +2185,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s */ .iwb-gal-head { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--iwb-border); } .iwb-gal-title { display: flex; align-items: baseline; gap: 8px; } -.iwb-gal-sel { font-size: 11px; color: var(--iwb-brand); } +.iwb-gal-sel { font-size: 11px; color: var(--iwb-brand-text, var(--iwb-brand)); } .iwb-gal-actions { display: flex; flex-wrap: wrap; gap: 6px; } .iwb-gal-actions .iwb-btn { flex: 0 0 auto; } .iwb-gal-actions .iwb-btn.iwb-gal-off { opacity: .45; } @@ -2215,7 +2256,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s } .iwb-dock-strip.left { left: var(--iwb-nav-w, 52px); border-right: 1px solid var(--iwb-border); } .iwb-dock-strip.right { right: 0; border-left: 1px solid var(--iwb-border); } -.iwb-dock-strip:hover { color: var(--iwb-text); background: var(--iwb-layer); } +.iwb-dock-strip:hover { color: var(--iwb-text); background: var(--iwb-hover); } .iwb-dock-drop { position: absolute; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--iwb-brand); pointer-events: none; } .iwb-dock-ghost { position: fixed; z-index: 1000; pointer-events: none; display: inline-flex; align-items: center; gap: 6px; @@ -2270,10 +2311,11 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s cursor: pointer; padding: 0; transition: background var(--tr-fast), color var(--tr-fast); } .iwb-nav-item .iwb-ic { width: 19px; height: 19px; } -.iwb-nav-item:hover { background: var(--iwb-layer); color: var(--iwb-text); } -.iwb-nav-item.on { background: color-mix(in srgb, var(--iwb-tint) 82%, #000); color: #fff; } -.iwb-nav-item.on:hover { background: color-mix(in srgb, var(--iwb-tint) 90%, #000); } -.theme-dark .iwb-nav-item.on { background: color-mix(in srgb, #ffffff 88%, #000); color: var(--iwb-text); } +.iwb-nav-item:hover { background: var(--iwb-hover); color: var(--iwb-text); } +/* 选中态用「反色」:底=文字色、字=页面底色 —— 两套主题都成立,不需要各写一条。 + 旧暗色是 #e0e0e0 底 + var(--iwb-text) 字,实测 1.3:1(白底白字)。 */ +.iwb-nav-item.on { background: var(--iwb-text); color: var(--iwb-bg); } +.iwb-nav-item.on:hover { background: color-mix(in srgb, var(--iwb-text) 88%, var(--iwb-bg)); } .ws-expanded .iwb-navrail { width: 52px; } /* ── 插件整页(v3.25.59)──────────────────────────────────────────────── */ @@ -2296,7 +2338,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-hotkey-help { display: flex; flex-direction: column; gap: 12px; } .iwb-hotkey-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; } .iwb-hotkey-group { display: flex; flex-direction: column; gap: 4px; min-width: 0; } -.iwb-hotkey-gname { margin: 2px 0 4px; font-size: 12px; font-weight: 700; color: var(--iwb-brand); letter-spacing: .04em; } +.iwb-hotkey-gname { margin: 2px 0 4px; font-size: 12px; font-weight: 700; color: var(--iwb-brand-text, var(--iwb-brand)); letter-spacing: .04em; } .iwb-hotkey-row { display: flex; align-items: center; gap: 8px; min-height: 22px; } .iwb-hotkey-name { flex: 1 1 auto; min-width: 0; font-size: 12px; color: var(--iwb-text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .iwb-hotkey-key { @@ -2329,7 +2371,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s color: color-mix(in srgb, var(--iwb-text) 42%, transparent); user-select: none; } -.theme-dark .iwb-tab-logotext { color: color-mix(in srgb, #ffffff 55%, transparent); } +.theme-dark .iwb-tab-logotext { color: var(--iwb-text-dim); } /* 画布内大图:paint 隔离 + 不让图片溢出重绘(v3.25.67 性能) */ .iwb-ref-single, .iwb-out-cell-img, .iwb-lod-thumb { contain: paint; } @@ -2512,3 +2554,13 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* v3.26.38:未进入编辑态的节点正文不参与指针/文本选择 —— 单击=选中节点,双击=编辑 */ .iwb-node textarea[readonly], .iwb-node input[readonly] { pointer-events: none; } + +/* ── 键盘焦点环兜底(v3.26.44 / D8)──────────────────────────────────── + 此前只有 .iwb-btn / .iwb-tab / .iwb-home-side-item 三处有焦点反馈,其余元素 Tab 过去 + 全靠 Chromium 默认蓝环(#005fcc)——与项目「全灰阶、无蓝」的配色约束冲突。 + 这里用 :where() 把权重压到 0,不抢任何已有的具体规则,只补没写的那部分。 + 放在文件末尾:同权重时靠后的生效,正好盖住 `.iwb-input { outline: none }` 这类重置。 */ +:where(button, a[href], input, textarea, select, [tabindex]):focus-visible { + outline: var(--iwb-focus-ring); + outline-offset: 2px; +} diff --git a/tests/_visual-tokens.spec.js-snapshots/01-home-dark-darwin.png b/tests/_visual-tokens.spec.js-snapshots/01-home-dark-darwin.png index 6c9a092..fc6ed66 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/01-home-dark-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/01-home-dark-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/01-home-light-darwin.png b/tests/_visual-tokens.spec.js-snapshots/01-home-light-darwin.png index 132f6b0..63aca8b 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/01-home-light-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/01-home-light-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/02-canvas-dark-darwin.png b/tests/_visual-tokens.spec.js-snapshots/02-canvas-dark-darwin.png index 90b3768..b4ea7ad 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/02-canvas-dark-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/02-canvas-dark-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/02-canvas-light-darwin.png b/tests/_visual-tokens.spec.js-snapshots/02-canvas-light-darwin.png index b02c1d6..1560e12 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/02-canvas-light-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/02-canvas-light-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/03-settings-dark-darwin.png b/tests/_visual-tokens.spec.js-snapshots/03-settings-dark-darwin.png index 23c80b8..9aa95ec 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/03-settings-dark-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/03-settings-dark-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/03-settings-light-darwin.png b/tests/_visual-tokens.spec.js-snapshots/03-settings-light-darwin.png index 9eee929..1cf9ac0 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/03-settings-light-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/03-settings-light-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/04-drawer-gallery-dark-darwin.png b/tests/_visual-tokens.spec.js-snapshots/04-drawer-gallery-dark-darwin.png index 8a5d9b9..de3037a 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/04-drawer-gallery-dark-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/04-drawer-gallery-dark-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/04-drawer-gallery-light-darwin.png b/tests/_visual-tokens.spec.js-snapshots/04-drawer-gallery-light-darwin.png index ca4fc9a..d69cc11 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/04-drawer-gallery-light-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/04-drawer-gallery-light-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/05-panel-promptlib-dark-darwin.png b/tests/_visual-tokens.spec.js-snapshots/05-panel-promptlib-dark-darwin.png index 20569da..7ef8be1 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/05-panel-promptlib-dark-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/05-panel-promptlib-dark-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/05-panel-promptlib-light-darwin.png b/tests/_visual-tokens.spec.js-snapshots/05-panel-promptlib-light-darwin.png index cd96f04..1a325d4 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/05-panel-promptlib-light-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/05-panel-promptlib-light-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/06-ctxmenu-dark-darwin.png b/tests/_visual-tokens.spec.js-snapshots/06-ctxmenu-dark-darwin.png index d99046c..f820271 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/06-ctxmenu-dark-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/06-ctxmenu-dark-darwin.png differ diff --git a/tests/_visual-tokens.spec.js-snapshots/06-ctxmenu-light-darwin.png b/tests/_visual-tokens.spec.js-snapshots/06-ctxmenu-light-darwin.png index aa9a2f0..9da0b7a 100644 Binary files a/tests/_visual-tokens.spec.js-snapshots/06-ctxmenu-light-darwin.png and b/tests/_visual-tokens.spec.js-snapshots/06-ctxmenu-light-darwin.png differ diff --git a/tests/page-chrome-regression-test.js b/tests/page-chrome-regression-test.js index 57b10cd..5d5c5cb 100644 --- a/tests/page-chrome-regression-test.js +++ b/tests/page-chrome-regression-test.js @@ -44,7 +44,7 @@ assert.ok(css.includes('.iwb-res-tabs')) assert.ok(css.includes('.iwb-home-card-title strong { font-size: 15px;')) // v3.1.0 首页灰色系:蓝 accent 清零(激活项/胶囊/chip/星标全走墨色或灰阶) assert.ok(/\.iwb-tab-home\.iwb-tab-active \{[^}]*background: transparent/.test(css)) // 首页按钮无选中底色 -assert.ok(/\.iwb-home-card \{[^}]*color-mix\(in srgb, var\(--iwb-panel\) 52%, var\(--iwb-home-bg\) 48%\)/.test(css)) // v3.1.0-pre.26:卡片随底色提亮,仍亮于首页底 +assert.ok(/\.iwb-home-card \{[^}]*background: var\(--iwb-bg-menu\)/.test(css)) // v3.26.44:卡片改用浮起层(亮=面板色,暗=比面板亮一档) assert.ok(!source.includes('iwb-home-card-active')) // 无「默认必有一个选中卡」的伪选中态 assert.ok(!/\.iwb-home-card-cat \{[^}]*iwb-brand/.test(css)) assert.ok(!/\.iwb-home-side-item\.active \{[^}]*iwb-brand/.test(css)) @@ -57,7 +57,10 @@ assert.ok(/\.iwb-home-main-head \.iwb-btn \{[^}]*color-mix/.test(css)) assert.ok(/\.iwb-home-main-head \.iwb-btn-primary \{[^}]*var\(--iwb-text2\)/.test(css)) assert.ok(/\.iwb-home-search \.iwb-input \{[^}]*color-mix/.test(css)) // v3.1.0 全灰阶收口:品牌 token=同亮度灰;画布选中标签=亮灰;app 内无蓝色 hex(节点色/连线) -assert.ok(css.includes('--iwb-brand: var(--iwb-text2)'), '品牌色默认跟随文字二级色(v3.25.83);自动配色会改写这个变量') +// v3.26.44 修正(D7):品牌色曾退化为 `var(--iwb-text2)` —— 主按钮与次要文字同值,没有强调语义。 +// 现在恢复成真正的强调色种子;「文字版」另拆 --iwb-brand-text(按对比度夹紧,暗色会明显更亮)。 +assert.ok(css.includes('--iwb-brand: #6b7280'), 'v3.26.44:品牌色恢复为独立强调色(D7),不再等于 --iwb-text2') +assert.ok(css.includes('--iwb-brand-text:'), '品牌色的文字版必须独立存在(暗色下填充色当文字只有 3.9:1)') // v3.26.42:半透明底色的基色由 --iwb-text 换成 --iwb-tint(tint 默认 = 派生文字色,视觉不变; // 分离的目的:外观面板调字体颜色时,悬停/标签/分隔底色不被连带改掉) assert.ok(/\.iwb-tab-active \{ background: color-mix\(in srgb, var\(--iwb-tint\) 9%, transparent\)/.test(css)) diff --git a/tests/theme-static-snapshot-test.js b/tests/theme-static-snapshot-test.js new file mode 100644 index 0000000..14b336f --- /dev/null +++ b/tests/theme-static-snapshot-test.js @@ -0,0 +1,111 @@ +// CSS 静态 token 必须等于 IWBThemeTokens.derive() 的输出(v3.26.44,M2/D2 守卫) +// +// 背景:style.css 的 :root / .theme-dark 是设计 token 的「静态快照」,用途是顶住 JS 执行前 +// 那一帧。历史上这两段是**另一套独立设计**(暗色是中灰底 #757575 + 深字 #111),与 derive +// 的「近黑底 + 浅字」同名不同值 —— 结果切主题像换了个产品,而且首屏会闪一下再跳变。 +// +// 这个测试把「快照 == 派生」钉成硬约束:改派生公式忘了同步 CSS,这里就红。 +// 结构层(chrome/home/dock/edge/hr/plugin 别名)刻意用 color-mix 表达关系式,跳过。 + +const fs = require('fs') +const path = require('path') + +const ROOT = path.resolve(__dirname, '..') +const css = fs.readFileSync(path.join(ROOT, 'style.css'), 'utf8') + +// 载入 theme-tokens(它是 UMD,挂到传入的对象上) +const sandbox = {} +new Function('window', fs.readFileSync(path.join(ROOT, 'src/theme-tokens.js'), 'utf8'))(sandbox) +const T = sandbox.IWBThemeTokens +assert(T && typeof T.derive === 'function', 'theme-tokens 未正确导出 derive') + +function assert (cond, msg) { + if (!cond) { console.error('✗ ' + msg); process.exit(1) } +} + +// 取出某个选择器块里的 `--var: value;` 声明 +function block (selector) { + const i = css.indexOf(selector + ' {') + assert(i >= 0, '找不到选择器块: ' + selector) + const start = css.indexOf('{', i) + let depth = 0 + for (let j = start; j < css.length; j++) { + if (css[j] === '{') depth++ + else if (css[j] === '}') { + depth-- + if (depth === 0) return css.slice(start + 1, j) + } + } + assert(false, '选择器块未闭合: ' + selector) +} + +function decls (body) { + const out = {} + // 去掉注释,避免注释里的示例声明被当成真声明 + const clean = body.replace(/\/\*[\s\S]*?\*\//g, '') + const re = /--(?:iwb-)?([a-z0-9-]+)\s*:\s*([^;]+);/g + let m + while ((m = re.exec(clean))) out[m[1]] = m[2].trim() + return out +} + +const rootVars = decls(block(':root')) +const darkVars = decls(block('.theme-dark')) + +// token 键(derive 返回的驼峰)→ CSS 变量名(kebab) +const KEYS = [ + 'bg', 'canvasBg', 'panel', 'layer', 'layer2', 'nodeBg', 'border', 'border2', + 'text', 'text2', 'textDim', 'canvasText', 'nodeText', 'nodeText2', 'tint', + 'surface', 'hover', 'menuBg', 'brand', 'brandText', 'gridDot', + 'pluginSurface', 'pluginCard', 'pluginInset', 'pluginHover', + 'err', 'ok', 'warn', 'onBrand', +] +// derive 键 → CSS 变量名(去掉 --iwb- 前缀)。canvasText 的变量名是特例(--iwb-color-text-on-canvas) +const VAR_ALIAS = { canvasText: 'color-text-on-canvas', menuBg: 'bg-menu' } +const varOf = (k) => VAR_ALIAS[k] || k.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase()) + +let checked = 0 +const bad = [] + +function checkOne (mode, dark, vars, table) { + const tokens = T.derive(T.DEFAULTS, dark) + for (const k of KEYS) { + const name = '--iwb-' + varOf(k) + const want = tokens[k] + const got = vars[varOf(k)] + if (!want) { bad.push(`${mode}: derive 未返回 ${k}`); continue } + if (!got) { bad.push(`${mode}: CSS 缺少 ${name}(期望 ${want})`); continue } + // 只比对字面量色值;color-mix/var() 表达式归结构层,跳过 + if (!/^#[0-9a-f]{6}$/i.test(got)) continue + checked++ + if (got.toLowerCase() !== String(want).toLowerCase()) { + bad.push(`${mode}: ${name} = ${got},derive 给 ${want}`) + } + } +} + +checkOne(':root', false, rootVars) +checkOne('.theme-dark', true, darkVars) + +// 结构层:CSS 用 color-mix 表达,必须与 derive 用同一组系数 +assert(/^color-mix\(in srgb, var\(--iwb-bg\) 60%, var\(--iwb-canvas-bg\) 40%\)$/.test(rootVars.chrome || ''), + 'chrome 公式应为 bg 60% + canvas 40%(derive 用 mix(bg, canvas, 0.4))') +assert(/^color-mix\(in srgb, var\(--iwb-chrome\) 55%, var\(--iwb-canvas-bg\) 45%\)$/.test(rootVars['dock-bg'] || ''), + 'dockBg 公式应为 chrome 55% + canvas 45%(derive 用 mix(chrome, canvas, 0.45);曾有三套写法)') +assert(/^color-mix\(in srgb, var\(--iwb-panel\) 55%, var\(--iwb-dock-bg\)\)$/.test(rootVars['dock-head-bg'] || ''), + 'dockHeadBg 公式应为 panel 55% + dockBg 45%') + +// 暗色块不应再重复定义结构层(否则又会分叉出第二套公式) +for (const k of ['chrome', 'home-bg', 'dock-bg', 'dock-head-bg']) { + assert(!darkVars[k], `暗色块不应重新定义 --iwb-${k}(应让 :root 的 color-mix 在 html 上重新求值)`) +} + +if (bad.length) { + console.error('✗ CSS 静态快照与 derive() 不一致:\n ' + bad.join('\n ')) + console.error('\n修法:改 style.css 里对应的字面量,或(若刚改了派生公式)用') + console.error(' node -e "const s={};new Function(\'window\',require(\'fs\').readFileSync(\'src/theme-tokens.js\',\'utf8\'))(s);console.log(s.IWBThemeTokens.derive(s.IWBThemeTokens.DEFAULTS,true))"') + console.error('重新生成快照。') + process.exit(1) +} + +console.log(`theme static snapshot checks passed(${checked} 个色值与 derive 一致,亮/暗各一套)`)