diff --git a/CHANGELOG.md b/CHANGELOG.md index f34efce..54b8128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,30 @@ > 3. 核验正式地址版本 → 之后才移动 `stable` / `stable-verified-<日期>` 标签、更新本 CHANGELOG、写 GitHub Release(`gh release create`)。 > 测试发现问题 → 改 → 再 `deploy:test`,正式环境不受影响。回滚点 `git reset --hard stable`。 +## v3.26.45(2026-11-23)浮层层级表 + 阴影四档:修好「弹窗里点保存看不到成功提示」 + +> **状态:待发布**(`verify:ci` 全绿、12 张视觉基线 0 diff;未打 tag) + +M4-B2 批次。用户能感知的只有一件事:**在弹窗/确认框里操作,成功提示现在看得见了**。其余是层级与阴影的归一。 + +**修掉一个「改 CSS 治不好」的层级 bug** + +- `.iwb-toast` 原本挂在 `.iwb-overlay` 内部,而 `.iwb-overlay` 自带 `z-index:100` + `position:fixed`,本身就是一个**堆叠上下文** —— 里面的 toast 写多少都压不过 portal 到 `body` 的弹窗(300)。所以此前「弹窗里点保存,什么都没发生」其实是提示被盖住了。 +- 修法不是调数字,而是把 toast 也 portal 到 `body`;随后层级数字才生效(实测:`elementFromPoint` 命中 toast 本身,而不是遮罩)。 + +**层级表(14 档,`--iwb-z-*`)** + +- 新增一张层级表,数值只在 `scripts/gen-tokens.js` 写一次:`ctx 90 / ctx-menu 91 / curtain 100 / command 120 / sheet 260 / sheet-menu 270 / modal 300 / modal-menu 310 / splash 400 / toast 500 / preview 800 / anchor 3200 / palette 3300 / alert 4000`。 +- 浮层族(弹窗、全窗口面板、命令面板、右键菜单、toast、锚定浮层、确认框、崩溃屏)全部改用 token,裸 `z-index` 取值种类从 42 降到 31。 +- 三条关系被测试钉死:`ctx-menu < sheet < modal`、`toast > modal`、`sheet-menu` 卡在 sheet 与 modal 之间。 + +**阴影四档 + 圆角归一** + +- 新增 `--iwb-elevation-1..4`(贴面 / 浮窗菜单 / 命令面板 / 弹窗),浮层从 8 种阴影写法收成 4 档;`.iwb-pop` 圆角 18px 归到 `radius-popover(14)`,浮层圆角只剩 1 种。 +- `--sh-sm/md/lg` 的引用归零,三个 legacy 名标 `@deprecated`(保留给外部样式,不删)。 + +**新增守卫**:`tests/overlay-layer-test.js` —— 层级表存在性、9 条顺序约束、浮层族禁裸 `z-index`、引用的 token 必须存在、toast 必须 portal。 + ## v3.26.44(2026-11-23)设计 token 体系重建:暗色真正变深、卡片内控件不再「挖黑洞」 本轮是 UI 设计语言的地基工程,观感变化集中在暗色主题。四个阶段(D1–D10 缺陷修复 → M0 视觉基线 → M1 清账 → M2 色彩模型 → M3 单一源)一次交付。 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bbfc579..47afdaf 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 118 个单测文件(jsdom 契约测试;2026-11-07 新增 sync-facts-guard(事实一致性)/ _helpers/source(统一源文本);2026-11-12 新增 provider-ping(测速 no-cors 兜底)) +test:unit 119 个单测文件(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/app.js b/app.js index 95bc76c..f8c6d67 100644 --- a/app.js +++ b/app.js @@ -8678,7 +8678,7 @@ items.push(el('button', { key: 'bgc', className: 'iwb-ctx-item', onClick: (e) => el('div', { className: 'iwb-ctx-sep' }, null), ), ) : null, - toast ? el('div', { className: 'iwb-toast iwb-toast-' + toast.type }, toast.text) : null, + toast ? ReactDOM.createPortal(el('div', { className: 'iwb-toast iwb-toast-' + toast.type }, toast.text), document.body) : null, // portal 到 body:.iwb-overlay 是堆叠上下文,内联再高也压不过弹窗(见 tests/overlay-layer-test.js) preview ? ReactDOM.createPortal(el(ImagePreview, { list: (typeof preview === 'string' ? [preview] : preview.list), idx: (typeof preview === 'string' ? 0 : preview.idx), onNav: (i) => setPreview({ list: (typeof preview === 'string' ? [preview] : preview.list), idx: i }), onClose: () => setPreview(null), onFlash: (t, ty) => setNotice({ type: ty === 'err' ? 'err' : 'ok', text: t }) }), document.body) : null, ), ) diff --git a/docs/plans/design-tokens-rollout.md b/docs/plans/design-tokens-rollout.md index e3730b2..df94b95 100644 --- a/docs/plans/design-tokens-rollout.md +++ b/docs/plans/design-tokens-rollout.md @@ -132,7 +132,7 @@ | 批次 | 范围 | 关键动作 | 预估 | 验收 | |---|---|---|---|---| | **B1 壳层** ✅ | `.iwb-tabstrip/.iwb-tab`(5 套)、`.iwb-dock-*`、`.iwb-toolbar*`、`.iwb-statusbar` | 页签收敛为 1 套(单框扁平 + 品牌高亮 + `--iwb-tab-height`);字号/圆角/间距换 token | 0.5d | 首页/画布截图;5 套类名只留 1 套 | -| **B2 浮层** | `.iwb-modal/.iwb-fullmask/.iwb-command/.iwb-ctxmenu/.iwb-toast/.iwb-pop*` | 圆角 → `radius-panel/popover`;阴影 → `elevation-2/3/4`;z-index → `--iwb-z-*`(toast 提到 modal 之上) | 0.5d | 遮罩/弹窗层级实测:toast 在确认框之上 | +| **B2 浮层** ✅ | `.iwb-modal/.iwb-fullmask/.iwb-command/.iwb-ctxmenu/.iwb-toast/.iwb-pop*` | 圆角 → `radius-panel/popover`;阴影 → `elevation-2/3/4`;z-index → `--iwb-z-*`(toast 提到 modal 之上) | 0.5d | 遮罩/弹窗层级实测:toast 在确认框之上 | | **B3 首页/库** | `.iwb-home-*/.iwb-lib-*/.iwb-res-*` | 间距归并(就近下取)、字号 8 档 | 0.5d | 首页截图;文案换行逐条看 | | **B4 设置/外观** | `.iwb-settings-modal/.iwb-appear-*/.iwb-setcell` | 控件统一 `pad-control` / `control-height` | 0.5d | 设置页截图 | | **B5 节点** | `.iwb-node*/.iwb-gen-*/.iwb-port` | 节点内字号 12/15 归口;圆角走 `--iwb-node-radius`;端口/小标签换 `bg-chip` | 1d | 画布截图(最复杂,单独一轮) | @@ -158,6 +158,31 @@ 已全部改成「不得复活」的反向断言。 3. 新增 token 后审计里的「定义但未引用」从 25 涨到 35:多出的 10 个是给 B2–B5 备的接口,不是死变量。 +**B2 执行结果(v3.26.45,2026-11-23)**: + +| 项 | 计划 | 实际 | 说明 | +|---|---|---|---| +| 层级表 | 9 档、裸值归零 | **14 档**,裸值种类 42 → 31 | 只覆盖浮层族。画布内端口/手柄/浮条属局部堆叠(B5);停靠栏 20–36 是**连续值**(lib 20 / drawer 22 / rightrail 24 / wsrail 25 / nav 35 / tabstrip 36),压成 3 档等于重排队一次堆叠,收益为零。1000 段的 `home-menu(1000/1001)` 未迁移,所以 `anchor/palette/alert` 保留 3200/3300/4000 | +| toast 层级 | 改 `z-index` 数字 | **改数字无效,改 portal** | `.iwb-overlay` 自带 `z-index:100` + `position:fixed`,是一个**堆叠上下文**:里面的 toast 写 500 也压不过 portal 到 body 的弹窗(300)。见下方「最大的坑」 | +| 阴影 | `elevation-2/3/4` | **4 档**(补 `elevation-1` 给贴面浮条),浮层 8 种写法 → 4 | 顺带把 `--sh-*` 的 3 处引用清零,三个 legacy 名全部 `@deprecated` | +| 圆角 | 全部换 token | 12 处,其中 11 处等值;`.iwb-pop` 18px → `radius-popover(14)` | 18px 在闭集之外且只此一处;归并后浮层圆角只剩 1 种 | +| 视觉基线 | 12 张 0 diff | ✅ 12/12 | 阴影 alpha `.28→.18`、`pop` 圆角 18→14 都在 playwright 阈值(0.2)内 | +| `verify:ci` | 全绿 | ✅ | 中途被 `source-text-ratchet`(`Workbench()` 行数 +1)和 `architecture-facts-guard`(单测数 118→119)拦了两次,见坑 2、3 | + +**最大的坑:堆叠上下文让「改数字」变成假修复。** +第一版只把 `.iwb-toast` 的 `z-index` 从 200 改成 `var(--iwb-z-toast)`(500),`verify:ci` 全绿、基线 0 diff, +看起来完工了。写探针实测才发现:toast 的父节点是 `.iwb-overlay`,它自己带 `z-index:100` —— +**子元素的层级被父级封住**,500 只在 overlay 内部有效,对外仍是 100,弹窗(300) 照样压着它。 +改成 `ReactDOM.createPortal(..., document.body)` 后,`elementFromPoint` 才命中 toast 本身。 +教训:`z-index` 的验收不能看「值对不对」,要看「同屏两个元素谁在上面」——不能只看 CSS,要跑命中测试。 + +**另两个坑**: +1. 比值更隐蔽的一类:`z-index: var(--iwb-z-modal)` 若变量名拼错,声明**整条失效并静默退化成 `auto`**, + 没有报错、没有控制台警告。所以守卫测试里有一条「引用的 z token 必须存在」(M5 的 token-lint 会扩到全仓)。 +2. `source-text-ratchet-test` 按**行数**钉 `Workbench()`:加 3 行注释也算「逻辑变长」。最终把说明压成一行行尾注释, + 长解释放在守卫测试与本文里 —— 这类解释写在棘轮文件里注定被删,写在测试里才活得住。 +3. 新增单测文件会让 `CONTRIBUTING.md` 的单测计数过期,`node scripts/sync-facts.js --write` 一条命令同步。 + **每批三条硬验收**: 1. 亮/暗两张截图 `0 diff`(B1 例外:允许 tab 视觉变化,需人工确认) 2. `token-audit.js` 对应计数下降 @@ -190,9 +215,9 @@ | 版本 | 内容 | 观感 | 备注 | |---|---|---|---| | 3.26.43 | M0 + M1 | 仅按钮高亮恢复 | 清账,风险最低 | -| 3.26.44 | M2 | **有变化** | 附亮/暗前后对比图;单独可回滚 | -| 3.27.0 | M3 | 零 | minor:新增公共 token 接口 | -| 3.27.1–3.27.6 | M4 六批 | 仅 B1 有变化 | 每批可单独发 | +| 3.26.44 | M2 + M3 + M4-B1 | **有变化** | 附亮/暗前后对比图;单独可回滚。M3 与 B1 搭同一版:M3 零观感、B1 只有标签变化,合起来只解释一次 | +| 3.26.45 | M4-B2 浮层 | 几乎零(阴影略软 + toast 可见性修复) | 层级表 + 阴影 4 档;toast 从「被弹窗盖住」修好,用户能感知的是「以前看不到的成功提示现在看得到」 | +| 3.26.46–3.26.49 | M4-B3–B6 | 仅 B5 有变化 | 每批可单独发 | | 3.27.7 | M5 | 零 | 闸门上线 | | 3.28.0 | M6 | 零 | 案例沉淀 | @@ -208,10 +233,10 @@ | 圆角档数 | 18 | 5 | 5 | | 间距档数 | 30 | ≤16 | ≤16 | | 字号写死处 | 281 | ≤60 | ≤20 | -| 圆角写死处 | 164 | ≤40 | ≤10 | +| 圆角写死处 | 164 | ≤40(B2 后 **142**) | ≤10 | | 间距写死处 | 644 | ≤200 | ≤80 | | 阴影写法种类 | 52 | ≤8 | 5 | -| z-index 取值种类 | 42 | ≤10 | 9 | +| z-index 取值种类 | 42 | ≤10(B2 后 **31**) | 9 | | `var(--iwb-layer)` 引用 | 59(一词多义) | 0(已拆) | 0 | | 暗色硬编码色行 | 24 | 0 | 0 | | text 对表面 <4.5 的格数 | 暗色 4 格 | 0 | 0 | diff --git a/docs/standards/design-tokens.md b/docs/standards/design-tokens.md index 7589e37..30f1899 100644 --- a/docs/standards/design-tokens.md +++ b/docs/standards/design-tokens.md @@ -256,6 +256,31 @@ - 控件在**面板/弹窗/抽屉**里 → 用 `--iwb-layer` / `--iwb-layer2`(凹槽语义不变)。 - 控件在**节点卡片**里 → 必须用 `--iwb-field`。判据不是「凹陷还是凸起」,而是「它贴在哪张卡片上」。 +### 1.10 M4-B2 浮层收敛执行记录(2026-11-23,v3.26.45) + +范围:`.iwb-modal / .iwb-fullmask / .iwb-command / .iwb-ctxmenu / .iwb-toast / .iwb-pop* / .iwb-ws-more`。 +产出:层级表 14 档(§3.6)+ 阴影 4 档(§3.5)+ 圆角全走 §3.4。 + +**最重要的一条不是 token,而是「改了数字也压不过」**: + +> `.iwb-toast` 原本挂在 `.iwb-overlay`(`z-index:100`)内部。`z-index` 只在**同一堆叠上下文**里比大小, +> 而 `.iwb-overlay` 自带 `z-index` + `position:fixed`,本身就是一个堆叠上下文 —— 里面的 toast 写 200、 +> 写 500、写 5000 都一样,整个子树被封在 100 这一层,压不过 portal 到 `body` 的弹窗(300)。 +> 所以「弹窗里点保存看不到提示」这条**只改 CSS 治不好**,必须 `ReactDOM.createPortal(..., document.body)`。 +> 实测(`document.elementFromPoint` 命中 toast 矩形中心):portal 前拿到遮罩,portal 后拿到 toast 自己。 + +| 项 | 计划 | 实际 | 说明 | +|---|---|---|---| +| 圆角 → `radius-*` | 全部替换 | 12 处等值替换;`.iwb-pop` 的 `18px` → `radius-popover(14)` | 18px 在 6 档闭集之外,且只此一处;4px 差值肉眼不可辨,归并后浮层圆角只剩 1 种 | +| 阴影 → `elevation-2/3/4` | 3 档 | **4 档**(多了 `elevation-1` 给贴面浮条),浮层族 8 种写法 → 4 档 | 顺便让 `--sh-*` 引用归零(3 处全换掉),三个 legacy 名进 `@deprecated` | +| z-index → `--iwb-z-*` | 9 档 | **14 档**,裸值种类 42 → 31 | 只覆盖浮层族;画布内端口/手柄是局部堆叠(B5),停靠栏 20–36 是连续值(压成 3 档等于重排队),见 §3.6 偏差 | +| toast 提到 modal 之上 | 改 CSS 数字 | **改数字无效** → 改 portal | 见上;`tests/overlay-layer-test.js` 同时钉「数字顺序」和「必须 portal」两件事 | +| 视觉基线 12 张 0 diff | 每批 0 | ✅ 12/12 通过 | 阴影 alpha 从 `.28` → `.18`、`.iwb-pop` 圆角 18→14 都在阈值内;`--iwb-z-*` 除 toast 外全部等值 | + +**新增守卫**:`tests/overlay-layer-test.js`(进 `test:unit`)—— 层级表存在性、9 条顺序约束、 +浮层族禁裸 `z-index`、引用必须存在、toast 必须 portal。这条测试替换掉的是一类**没有报错的错**: +`z-index` 拼错变量名时会静默退化为 `auto`,只在特定操作顺序下露馅。 + ## 2. 目标架构 ### 2.1 三层模型(与 Primer / Ant Design v5 / Radix 同一套骨架) @@ -437,44 +462,76 @@ L3 Contract ── 组件整体换肤时才加,能不建就不建 ### 3.4 圆角 -| L2 | 值 | 用在哪 | 归并掉 | -|---|---|---|---| -| `--iwb-radius-control` | 6px | 按钮、输入框、小标签 | 1,2,3,4,5 | -| `--iwb-radius-card` | 8px | 卡片、列表项、菜单项 | 7,9 | -| `--iwb-radius-popover` | 10px | 气泡、下拉、toast | 11 | -| `--iwb-radius-panel` | 14px | 面板、弹窗、全屏浮层 | 12,16,18,20,22 | -| `--iwb-radius-pill` | 999px | 胶囊、开关、头像 | — | +**已落地(v3.26.44,M4-B1)**:6 档,全部在 `SCALE` 表里。 -> **待拍板**:面板统一到 14(现状多数:modal/fullmask/floatbar/crash 都是 14)还是 12(工具栏/菜单/命令面板)?见 §9-①。 +| token | 值 | 用在哪 | 归并掉 | +|---|---|---|---| +| `--iwb-radius-chip` | 6px | 胶囊、小标签 | 1,2,3,4,5 | +| `--iwb-radius-control` | 8px | 按钮、输入框、菜单项 | 7,9 | +| `--iwb-radius-card` | 10px | 卡片、toast、列表项、浮层内小卡 | 11 | +| `--iwb-radius-panel` | 12px | 面板、工具栏、命令面板、右键菜单 | 12,13 | +| `--iwb-radius-popover` | 14px | 弹窗、全窗口面板、锚定浮层、节点 | 16,18,20,22 | +| `--iwb-radius-full` | 999px | 药丸、开关、头像 | — | + +> **与初版计划的偏差**:计划里 `control 6 / card 8 / popover 10 / panel 14`,落地按**现状分布**定档 +> (12px 与 14px 是既有主力,先认它们为 panel/popover 再往上收),否则 B1 就不是等值迁移而是重画。 +> 实际使用频次(`grep -c 'border-radius: 1[0-9]px'`)也支持这个分档:12px 最多。 > 节点圆角是**用户可调项**(`--iwb-node-radius`,外观 → 画布),不进 L2 闭集。 ### 3.5 高度(elevation) +**已落地(v3.26.45,M4-B2)**:4 档,按「离内容多远」分,不按组件分。 + | token | 亮色 | 暗色 | 用在哪 | |---|---|---|---| -| `--iwb-elevation-0` | `none` | `none` | 平铺卡片 | -| `--iwb-elevation-1` | `0 1px 2px rgba(0,0,0,.06)` | 同 | 输入聚焦、贴边 | -| `--iwb-elevation-2` | `0 4px 16px rgba(0,0,0,.12)` | `.18` | 工具条、浮动条 | -| `--iwb-elevation-3` | `0 8px 30px rgba(0,0,0,.18)` | `.30` | 菜单、气泡、toast | -| `--iwb-elevation-4` | `0 16px 48px rgba(0,0,0,.24)` | `.40` | 模态、全屏浮层 | +| `--iwb-elevation-1` | `0 2px 8px rgba(0,0,0,.12)` | α `.40` | 贴面浮层:浮动条、状态栏、HUD | +| `--iwb-elevation-2` | `0 10px 30px rgba(0,0,0,.18), 0 1px 3px rgba(0,0,0,.10)` | α `.55/.40` | 浮窗、菜单、右键、toast | +| `--iwb-elevation-3` | `0 18px 56px rgba(0,0,0,.26)` | α `.62` | 命令面板、锚定大浮层、确认框 | +| `--iwb-elevation-4` | `0 24px 64px rgba(0,0,0,.30)` | α `.70` | 弹窗、全窗口面板 | -**暗色补充规则**:暗色下阴影几乎不可见,浮层层次改由**描边**承担 → 暗色浮层必须同时有 `border: 1px solid var(--iwb-color-border)`。这是替代 52 种硬编码阴影的关键(暗色里 `rgba(0,0,0,.25)` 等于没有)。 +值写在 `scripts/gen-tokens.js` 的 `LIGHT_SHADOW` / `DARK_SHADOW` 常量表里(与 `--sh-*` 同一机制: +它们是「主题皮肤」而不是派生色,所以不进 `derive()`,见 §1.8 已知限制)。 + +> **与初版计划的偏差**:计划是 5 档(含 `elevation-0: none`)。落地去掉 0 档 —— 「没有阴影」不需要 +> token,写 `box-shadow: none` 更清楚。档数从 5 降到 4 也符合实测分布:现有 46 种阴影写法里, +> 真正表达「不同层深」的只有 4 组,其余是同一档的手抖差异(`.12/.14/.15`、`28px/30px/32px`)。 +> +> **暗色必须靠描边**:暗色下 `rgba(0,0,0,.x)` 画不出形(底已近黑),所以浮层一律带 +> `border: 1px solid var(--iwb-border)` —— 这不是额外美化,是暗色能分辨层级的唯一手段。 ### 3.6 层级(z-index) +**已落地(v3.26.45,M4-B2)**:14 档,数值只在 `SCALE` 表里写一次,组件引名字。 + | token | 值 | 谁用 | |---|---|---| -| `--iwb-z-base` | 0 | 普通流 | -| `--iwb-z-node` | 1 | 画布节点 | -| `--iwb-z-node-active` | 10 | 选中/拖拽节点 | -| `--iwb-z-chrome` | 20 | 顶栏、停靠栏、状态栏 | -| `--iwb-z-panel` | 30 | 抽屉、右栏、库面板 | -| `--iwb-z-popover` | 40 | 菜单、气泡、tooltip、**插件上限** | -| `--iwb-z-modal` | 50 | 模态、确认框 | -| `--iwb-z-toast` | 60 | toast、通知(**必须在模态之上**,修 §1.3-⑥) | -| `--iwb-z-debug` | 90 | 崩溃页、诊断浮层 | +| `--iwb-z-ctx` | 90 | 右键遮罩 `.iwb-ctxmask` | +| `--iwb-z-ctx-menu` | 91 | 右键菜单 `.iwb-ctxmenu` | +| `--iwb-z-curtain` | 100 | 应用遮罩 `.iwb-overlay`、图片预览底 | +| `--iwb-z-command` | 120 | 命令面板 `.iwb-command-mask` | +| `--iwb-z-sheet` | 260 | 全窗口面板 `.iwb-fullmask`(资源中心) | +| `--iwb-z-sheet-menu` | 270 | 面板内 portal 菜单(提示词/节点组「移动到分组」) | +| `--iwb-z-modal` | 300 | 弹窗 `.iwb-modal-mask` | +| `--iwb-z-modal-menu` | 310 | 侧栏里挂 body 的菜单 `.iwb-ws-more` | +| `--iwb-z-splash` | 400 | 启动页 | +| `--iwb-z-toast` | 500 | toast(**必须高于 modal**,见 §1.10) | +| `--iwb-z-preview` | 800 | 图片预览 | +| `--iwb-z-anchor` | 3200 | 锚定浮层 `.iwb-pop-anchor`(外观面板挂在设置弹窗里) | +| `--iwb-z-palette` | 3300 | 背景色板 host | +| `--iwb-z-alert` | 4000 | 确认框 / 崩溃屏(最后一道) | -规则:**禁止出现裸数字 z-index**;插件不得超过 `--iwb-z-popover`(40),需要更高必须走宿主 API 由宿主安排。 +三条硬关系(`tests/overlay-layer-test.js` 逐条断言,改数值前先读): + +1. `ctx-menu(91) < sheet(260) < modal(300)` —— 层越上数字越大,不许交叉; +2. `toast(500) > modal(300)` —— 提示条永远在最上面,否则「操作成功」等于没提示; +3. `sheet-menu(270)` 卡在 sheet 与 modal 之间 —— 它是面板的子菜单,不该越到弹窗之上。 + +> **与初版计划的偏差**:计划是 9 档(`base/node/chrome/panel/popover/modal/toast/debug`),且要让 +> 裸 z-index 归零。落地保留 14 档、且只覆盖**浮层族**,两条理由: +> ① 计划里的 `node/chrome/panel` 三档在实现里是 20–36 的一段连续值(停靠栏 20/22/24/25、导航 35、标签条 36), +> 硬压成 3 个值等于重排队一次堆叠,收益为零、风险不小; +> ② 1000 段还有未迁移的 `home-menu(1000/1001)`,把高段位压到 1000 会与它交错,所以 `anchor/palette/alert` +> 保留历史数值(3200/3300/4000),等 M5 的 token-lint 把裸值清零后再统一。 ### 3.7 动效 diff --git a/package.json b/package.json index a8e5fee..894f239 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "image-workbench-web", "private": true, - "version": "3.26.44", + "version": "3.26.45", "description": "Browser-based node canvas image workbench", "scripts": { "build": "node scripts/build.js && node scripts/copy-plugins.js", @@ -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/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: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/overlay-layer-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/gen-tokens.js b/scripts/gen-tokens.js index a52e316..4628806 100644 --- a/scripts/gen-tokens.js +++ b/scripts/gen-tokens.js @@ -124,6 +124,32 @@ const SCALE = [ ['--iwb-chrome-h', '36px', '顶部标签条高度:tabstrip / dockarea / home-panel 三处共用(原来各写一遍 36px)'], ['--iwb-tab-h', '28px', '标签高度'], ['--iwb-tab-radius', '7px', '标签圆角'], + + /* ── 层级表(M4-B2)─────────────────────────────────────────────── + * 迁移前 z-index 有 42 种取值,其中「谁盖谁」全靠散落在各处的数字对撞,出过两次真 bug: + * ① toast(200) 低于弹窗(300) → 弹窗里点保存看不到提示; + * ② 资源中心的右键菜单(91) 被全窗口面板(260) 盖住 → 只能挪到 270 打补丁。 + * 现在数值只在这张表里写,组件引名字。三条关系必须成立,改数字前先读这三条: + * A. ctx-menu(91) < sheet(260) < modal(300):层越上,数字越大,不许交叉; + * B. toast(500) > modal(300):提示条永远在最上面,否则「操作成功」等于没提示; + * C. sheet-menu(270) 是「容器内 portal 菜单」,> sheet 且 < modal(它是面板的子菜单,不该越过弹窗)。 + * 高段位(3200/3300/4000)保留历史数值:1000 段还有未迁移的 home-menu(1000/1001), + * 贸然压缩会和它交错,等 M5 的 token-lint 把裸 z-index 清零后再统一。 + */ + ['--iwb-z-ctx', '90', '右键遮罩'], + ['--iwb-z-ctx-menu', '91', '右键菜单'], + ['--iwb-z-curtain', '100', '应用遮罩 / 图片预览底'], + ['--iwb-z-command', '120', '命令面板(⌘K)'], + ['--iwb-z-sheet', '260', '全窗口面板(资源中心)'], + ['--iwb-z-sheet-menu', '270', '面板内 portal 菜单:> sheet、< modal'], + ['--iwb-z-modal', '300', '弹窗 + 遮罩'], + ['--iwb-z-modal-menu', '310', '侧栏/弹窗里挂 body 的菜单'], + ['--iwb-z-splash', '400', '启动页'], + ['--iwb-z-toast', '500', '提示条:必须高于弹窗'], + ['--iwb-z-preview', '800', '图片预览(全屏)'], + ['--iwb-z-anchor', '3200', '锚定浮层:挂 body 的面板/首页菜单'], + ['--iwb-z-palette', '3300', '背景色板 host(含锚定浮层)'], + ['--iwb-z-alert', '4000', '确认框 / 崩溃屏(最后一道)'], ] /* 只在亮色出现的结构/契约声明(暗色由 :root 的 color-mix 在 html 上重新求值,或单独覆盖) */ @@ -179,11 +205,26 @@ const DARK_SHADOW = [ ['--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)'], + /* 暗色下阴影本来就画不出形(底已经近黑),必须靠「更大的不透明度 + 更大的扩散」压出层次差 */ + ['--iwb-elevation-1', '0 2px 8px rgba(0, 0, 0, 0.40)'], + ['--iwb-elevation-2', '0 8px 28px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.40)'], + ['--iwb-elevation-3', '0 18px 56px rgba(0, 0, 0, 0.62)'], + ['--iwb-elevation-4', '0 24px 64px rgba(0, 0, 0, 0.70)'], ] const LIGHT_SHADOW = [ ['--sh-sm', '0 2px 8px rgba(0, 0, 0, 0.12)', '@deprecated → M3 的 --iwb-elevation-1'], ['--sh-md', '0 6px 20px rgba(0, 0, 0, 0.16)', null], ['--sh-lg', '0 12px 32px rgba(0, 0, 0, 0.24)', null], + /* ── 阴影四档(M4-B2)──────────────────────────────────────────── + * 迁移前浮层有 8 种写法(52 种全局),同一层的两个菜单阴影不一样 —— 层深不再表达「离内容多远」。 + * 现在按「离内容多远」分四档,一档一个值: + * 1 贴面(浮动条/状态栏/HUD)· 2 浮窗/菜单/toast · 3 命令面板/锚定大浮层 · 4 弹窗/全窗口面板 + * 只改形,不改色:颜色仍是中性黑(暗色另有覆盖)。 + */ + ['--iwb-elevation-1', '0 2px 8px rgba(0, 0, 0, 0.12)', '贴面浮层:浮动条 / 状态栏'], + ['--iwb-elevation-2', '0 10px 30px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.10)', '浮窗 / 菜单 / toast'], + ['--iwb-elevation-3', '0 18px 56px rgba(0, 0, 0, 0.26)', '命令面板 / 锚定大浮层'], + ['--iwb-elevation-4', '0 24px 64px rgba(0, 0, 0, 0.30)', '弹窗 / 全窗口面板'], ] function decl ([name, value, note]) { @@ -275,6 +316,8 @@ function inferType (value, name) { if (/^-?[\d.]+px$/.test(value)) return 'dimension' if (/^-?[\d.]+m?s$/.test(value)) return 'duration' if (/\d+px [\d.]+px/.test(value)) return 'shadow' + // 层级是纯数字(z-index 认的是整数),DTCG 里就是 number + if (/^--(?:iwb-)?z-/.test(name) && /^\d+$/.test(value)) return 'number' // 过渡是「时长 + 缓动」的复合值,DTCG 里是两种类型:时长给 $value,缓动放 $description if (/^--tr-/.test(name) && /^[\d.]+m?s\s+\S+$/.test(value)) return 'duration' return null @@ -290,7 +333,9 @@ function groupOf (name) { if (/^fs-/.test(n)) return 'legacy.font' if (/^font-/.test(n)) return 'font.size' if (/^tr-/.test(n)) return 'motion' + if (/^elevation-/.test(n)) return 'shadow.elevation' if (/^sh-/.test(n)) return 'shadow' + if (/^z-/.test(n)) return 'z' if (n === 'grid-dot') return 'color' if (/^(grid-|nav-|node-radius|node-sel-w|edge-w|edge-dash|chrome-h|tab-h|tab-radius)/.test(n)) return 'layout' if (/^plugin-/.test(n)) return 'color.plugin' @@ -308,7 +353,9 @@ function dtcgKey (name) { if (/^fs-/.test(n)) return n.slice(3) if (/^font-/.test(n)) return n.slice(5) if (/^tr-/.test(n)) return n.slice(3) + if (/^elevation-/.test(n)) return n.slice(10) if (/^sh-/.test(n)) return n.slice(3) + if (/^z-/.test(n)) return n.slice(2) if (/^plugin-/.test(n)) return n.slice(7) return n } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 0568b08..1e33776 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "../node_modules/@tauri-apps/cli/config.schema.json", "productName": "image-workbench", - "version": "3.26.44", + "version": "3.26.45", "identifier": "com.malongan.imageworkbench", "build": { "frontendDist": "../dist", diff --git a/src/design-tokens.css b/src/design-tokens.css index 6e2ecf9..035d827 100644 --- a/src/design-tokens.css +++ b/src/design-tokens.css @@ -118,10 +118,28 @@ --iwb-chrome-h: 36px; /* 顶部标签条高度:tabstrip / dockarea / home-panel 三处共用(原来各写一遍 36px) */ --iwb-tab-h: 28px; /* 标签高度 */ --iwb-tab-radius: 7px; /* 标签圆角 */ + --iwb-z-ctx: 90; /* 右键遮罩 */ + --iwb-z-ctx-menu: 91; /* 右键菜单 */ + --iwb-z-curtain: 100; /* 应用遮罩 / 图片预览底 */ + --iwb-z-command: 120; /* 命令面板(⌘K) */ + --iwb-z-sheet: 260; /* 全窗口面板(资源中心) */ + --iwb-z-sheet-menu: 270; /* 面板内 portal 菜单:> sheet、< modal */ + --iwb-z-modal: 300; /* 弹窗 + 遮罩 */ + --iwb-z-modal-menu: 310; /* 侧栏/弹窗里挂 body 的菜单 */ + --iwb-z-splash: 400; /* 启动页 */ + --iwb-z-toast: 500; /* 提示条:必须高于弹窗 */ + --iwb-z-preview: 800; /* 图片预览(全屏) */ + --iwb-z-anchor: 3200; /* 锚定浮层:挂 body 的面板/首页菜单 */ + --iwb-z-palette: 3300; /* 背景色板 host(含锚定浮层) */ + --iwb-z-alert: 4000; /* 确认框 / 崩溃屏(最后一道) */ /* —— 阴影 —— */ --sh-sm: 0 2px 8px rgba(0, 0, 0, 0.12); /* @deprecated → M3 的 --iwb-elevation-1 */ --sh-md: 0 6px 20px rgba(0, 0, 0, 0.16); --sh-lg: 0 12px 32px rgba(0, 0, 0, 0.24); + --iwb-elevation-1: 0 2px 8px rgba(0, 0, 0, 0.12); /* 贴面浮层:浮动条 / 状态栏 */ + --iwb-elevation-2: 0 10px 30px rgba(0, 0, 0, 0.18), 0 1px 3px rgba(0, 0, 0, 0.10); /* 浮窗 / 菜单 / toast */ + --iwb-elevation-3: 0 18px 56px rgba(0, 0, 0, 0.26); /* 命令面板 / 锚定大浮层 */ + --iwb-elevation-4: 0 24px 64px rgba(0, 0, 0, 0.30); /* 弹窗 / 全窗口面板 */ } /* 暗色主题:html.theme-dark @@ -172,6 +190,10 @@ --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); + --iwb-elevation-1: 0 2px 8px rgba(0, 0, 0, 0.40); + --iwb-elevation-2: 0 8px 28px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.40); + --iwb-elevation-3: 0 18px 56px rgba(0, 0, 0, 0.62); + --iwb-elevation-4: 0 24px 64px rgba(0, 0, 0, 0.70); } /* 亮色主题的生图动效 token:与暗色同结构,色取品牌色 */ diff --git a/style.css b/style.css index 0ba04f2..dd41c4b 100644 --- a/style.css +++ b/style.css @@ -193,8 +193,8 @@ button { font-family: inherit; } .iwb-mini-node { position: absolute; border-radius: 2px; opacity: 0.85; } .iwb-mini-view { position: absolute; border: 1px solid var(--iwb-brand); border-radius: 2px; pointer-events: none; } -.iwb-modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 300; display: flex; align-items: center; justify-content: center; } -.iwb-modal { width: 680px; max-width: calc(100vw - 60px); max-height: 82vh; background: var(--iwb-panel); border: 1px solid var(--iwb-border2); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; } +.iwb-modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: var(--iwb-z-modal); display: flex; align-items: center; justify-content: center; } +.iwb-modal { width: 680px; max-width: calc(100vw - 60px); max-height: 82vh; background: var(--iwb-panel); border: 1px solid var(--iwb-border2); border-radius: var(--iwb-radius-popover); display: flex; flex-direction: column; overflow: hidden; } .iwb-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--iwb-border); } .iwb-modal-body { padding: 14px 16px; overflow: auto; display: flex; flex-direction: column; gap: 10px; max-height: 62vh; } .iwb-modal-foot { padding: 12px 16px; border-top: 1px solid var(--iwb-border); display: flex; justify-content: flex-end; } @@ -230,7 +230,7 @@ button { font-family: inherit; } .iwb-gmgr-count { font-size: 11px; color: var(--iwb-text2); white-space: nowrap; } /* 提示词库:全屏管理视图(面板占满视口,内部区域各自滚动,适配小分辨率) */ /* 提示词库活动窗口(可拖动标题栏移动、右下角缩放;尺寸/位置由 fsWin 控制) */ -.iwb-fullmask { position: fixed; z-index: 260; display: flex; background: var(--iwb-panel); border: 1px solid var(--iwb-border2); border-radius: 14px; box-shadow: var(--sh-lg); overflow: hidden; padding: 0; } +.iwb-fullmask { position: fixed; z-index: var(--iwb-z-sheet); display: flex; background: var(--iwb-panel); border: 1px solid var(--iwb-border2); border-radius: var(--iwb-radius-popover); box-shadow: var(--iwb-elevation-4); overflow: hidden; padding: 0; } .iwb-fullpanel { width: 100%; height: 100%; max-width: none; max-height: none; background: var(--iwb-panel); border: none; border-radius: 0; box-shadow: none; display: flex; flex-direction: column; overflow: hidden; } .iwb-full-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--iwb-border); flex: 0 0 auto; cursor: move; user-select: none; } .iwb-full-head .iwb-toolbar-title { white-space: nowrap; } @@ -321,7 +321,7 @@ button { font-family: inherit; } .iwb-ref-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; } .iwb-ref-single { width: 100%; min-height: 60px; max-height: 340px; object-fit: contain; object-position: center; border-radius: 6px; border: 1px solid var(--iwb-border); background: var(--iwb-layer2); cursor: move; } -.iwb-history { position: absolute; left: 12px; right: 12px; bottom: 46px; background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: 12px; z-index: 30; box-shadow: 0 8px 30px rgba(0,0,0,0.25); padding: 8px 12px; max-height: 180px; display: flex; flex-direction: column; } +.iwb-history { position: absolute; left: 12px; right: 12px; bottom: 46px; background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-panel); z-index: 30; box-shadow: var(--iwb-elevation-2); padding: 8px 12px; max-height: 180px; display: flex; flex-direction: column; } .iwb-history-grid { display: flex; gap: 8px; overflow-x: auto; padding: 8px 2px; flex: 1; } .iwb-history-item { position: relative; flex: 0 0 110px; } .iwb-history-item img { width: 110px; height: 82px; object-fit: contain; border-radius: 6px; border: 1px solid var(--iwb-border); background: var(--iwb-layer2); cursor: pointer; } @@ -459,7 +459,7 @@ button { font-family: inherit; } .iwb-node-fixed .iwb-textarea { flex: 1 1 auto; max-height: none; min-height: 56px; height: auto !important; } /* ---- v3:toast 提示 ---- */ -.iwb-toast { position: fixed; left: 50%; top: 56px; transform: translateX(-50%); z-index: 200; background: var(--iwb-panel); border: 1px solid var(--iwb-border2); border-radius: 10px; padding: 10px 18px; box-shadow: 0 8px 30px rgba(0,0,0,0.3); font-size: 13px; font-weight: 600; animation: iwb-fadein 0.18s ease; } +.iwb-toast { position: fixed; left: 50%; top: 56px; transform: translateX(-50%); z-index: var(--iwb-z-toast); background: var(--iwb-panel); border: 1px solid var(--iwb-border2); border-radius: var(--iwb-radius-card); padding: 10px 18px; box-shadow: var(--iwb-elevation-2); font-size: var(--iwb-font-md); font-weight: 600; animation: iwb-fadein 0.18s ease; } .iwb-toast-ok { border-left: 3px solid var(--iwb-brand); } .iwb-toast-err { border-left: 3px solid var(--iwb-err); } @keyframes iwb-fadein { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translate(-50%, 0); } } @@ -471,7 +471,7 @@ button { font-family: inherit; } /* 展开态标题行右侧 ⋯ 三点菜单(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-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 { position: fixed; z-index: var(--iwb-z-modal-menu); min-width: 210px; padding: 6px; background: var(--iwb-bg-menu); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-panel); box-shadow: var(--iwb-elevation-2); 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-text, var(--iwb-brand)); } @@ -485,7 +485,7 @@ button { font-family: inherit; } /* 组合来源停用标记 */ .iwb-combine-src-off { color: var(--iwb-text2); opacity: 0.55; text-decoration: line-through; } /* 页面加载动画: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 { position: fixed; inset: 0; z-index: var(--iwb-z-splash); 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-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; } @@ -706,8 +706,8 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-node.iwb-conn-ok { border-color: var(--iwb-ok) !important; box-shadow: 0 0 0 2px color-mix(in srgb, var(--iwb-ok) 45%, transparent), 0 6px 20px rgba(0,0,0,0.25) !important; } .iwb-node.iwb-conn-bad { border-color: var(--iwb-err) !important; box-shadow: 0 0 0 2px color-mix(in srgb, var(--iwb-err) 55%, transparent), 0 6px 20px rgba(0,0,0,0.25) !important; } .iwb-conn-hint { position: absolute; left: 8px; right: 8px; bottom: 6px; z-index: 6; padding: 4px 6px; border-radius: 5px; color: var(--iwb-err); background: rgba(254, 226, 226, 0.96); border: 1px solid rgba(239, 68, 68, 0.35); font-size: 11px; line-height: 1.25; pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } -.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-mask { position: fixed; inset: 0; z-index: var(--iwb-z-command); 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: var(--iwb-radius-panel); box-shadow: var(--iwb-elevation-3); 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-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; } @@ -756,10 +756,10 @@ 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-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; } +.iwb-ctxmask { position: fixed; inset: 0; background: transparent; z-index: var(--iwb-z-ctx); } +.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: var(--iwb-radius-panel); box-shadow: var(--iwb-elevation-2); z-index: var(--iwb-z-ctx-menu); 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-ctxmenu.iwb-lib-group-menu { z-index: var(--iwb-z-sheet-menu); /* 面板内的 portal 菜单:> sheet、< modal,见 tokens 层级表 */ } .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); } @@ -901,7 +901,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* 大图预览:左右切换 + 下载条 */ -.iwb-imgpreview { position: fixed; inset: 0; background: rgba(10, 12, 18, 0.92); z-index: 100; display: flex; align-items: center; justify-content: center; cursor: zoom-out; } +.iwb-imgpreview { position: fixed; inset: 0; background: rgba(10, 12, 18, 0.92); z-index: var(--iwb-z-preview); display: flex; align-items: center; justify-content: center; cursor: zoom-out; } /* 预览图自适应宽+高:同时约束横向与纵向,保持宽高比居中显示,不溢出(图库预览已取完整原图,可能很大/超高/超宽) */ .iwb-imgpreview img { max-width: 92vw; max-height: 88vh; width: auto; height: auto; object-fit: contain; border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,0.5); cursor: default; } .iwb-prev-nav { position: fixed; top: 50%; transform: translateY(-50%); width: 46px; height: 64px; border: none; border-radius: 8px; background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 30px; cursor: pointer; z-index: 101; } @@ -1372,7 +1372,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-home-menu-btn:hover { background: var(--iwb-layer2); border-color: var(--iwb-border2); color: var(--iwb-text); } .iwb-home-menu-btn .iwb-ic { width: 18px; height: 18px; } .iwb-home-menu-mask { position: fixed; inset: 0; z-index: 200; } -.iwb-home-menu { position: fixed; width: 220px; background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: 12px; box-shadow: var(--sh-lg); padding: 6px; display: flex; flex-direction: column; gap: 2px; box-sizing: border-box; } +.iwb-home-menu { position: fixed; width: 220px; background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-panel); box-shadow: var(--iwb-elevation-2); padding: 6px; display: flex; flex-direction: column; gap: 2px; box-sizing: border-box; } .iwb-home-menu-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: transparent; color: var(--iwb-text); font-size: 14px; cursor: pointer; border-radius: 8px; text-align: left; width: 100%; box-sizing: border-box; } .iwb-home-menu-item:hover { background: var(--iwb-layer2); } .iwb-home-menu-item .iwb-ic { color: var(--iwb-text2); } @@ -1382,7 +1382,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* 顶层弹层层级:菜单 & 放大图必须盖过画布/资源中心/遮罩 */ .iwb-home-menu-mask { z-index: 1000; } .iwb-home-menu { z-index: 1001; } -.iwb-imgpreview { z-index: 800; } +.iwb-imgpreview { z-index: var(--iwb-z-preview); } .iwb-home-menu-ver { display: block; padding: 8px 12px; font-size: 11px; color: var(--iwb-text2); text-align: left; border-top: 1px solid var(--iwb-border); margin-top: 4px; } /* 资源面板 4 角缩放手柄 */ @@ -1520,8 +1520,8 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-setopen { flex: 0 0 auto; } /* ===== v3.86.5 图像设置:贴节点浮层(popover)形态 ===== */ -.iwb-pop-anchor { position: fixed; z-index: 3200; } -.iwb-pop { width: 380px; max-width: calc(100vw - 16px); background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: 18px; box-shadow: 0 18px 54px rgba(28,25,23,.16); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 32px); overflow-y: auto; } +.iwb-pop-anchor { position: fixed; z-index: var(--iwb-z-anchor); } +.iwb-pop { width: 380px; max-width: calc(100vw - 16px); background: var(--iwb-panel); border: 1px solid var(--iwb-border); border-radius: var(--iwb-radius-popover); box-shadow: var(--iwb-elevation-3); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 32px); overflow-y: auto; } .iwb-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; } .iwb-pop-title { font-weight: 700; color: var(--iwb-text); } .iwb-pop-body { display: flex; flex-direction: column; gap: 12px; } @@ -1607,7 +1607,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* ── v3.87.6 崩溃可观测性:错误边界兜底 UI + 设置里的「诊断」页 ── */ .iwb-crash-retry { margin-top: 6px; } -.iwb-crash-screen { position: fixed; inset: 0; z-index: 4000; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--iwb-bg); } +.iwb-crash-screen { position: fixed; inset: 0; z-index: var(--iwb-z-alert); display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--iwb-bg); } .iwb-crash-card { max-width: 620px; width: 100%; padding: 20px 22px; border: 1px solid var(--iwb-border); border-radius: 14px; background: var(--iwb-panel); display: flex; flex-direction: column; gap: 10px; } .iwb-crash-title { font-size: 16px; font-weight: 700; } .iwb-crash-msg { font-size: 13px; color: var(--iwb-text2); word-break: break-word; max-height: 30vh; overflow: auto; } @@ -1805,7 +1805,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-pick-caret .iwb-ic { width: 14px; height: 14px; opacity: .75; } /* 节点背景色色板(2026-11-01):6 个预设色块 + 「无」。 纯静态 CSS,无动画/滤镜 ⇒ 不改色时开销为 0;改色只重绘该节点区域。 */ -.iwb-pop.iwb-bg-palette { display: flex; flex-direction: row; align-items: center; gap: 8px; width: auto; max-width: none; padding: 8px 10px; border-radius: 12px; } +.iwb-pop.iwb-bg-palette { display: flex; flex-direction: row; align-items: center; gap: 8px; width: auto; max-width: none; padding: 8px 10px; border-radius: var(--iwb-radius-panel); } .iwb-bg-swatch { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--iwb-border); cursor: pointer; padding: 0; flex: 0 0 auto; transition: transform .12s, box-shadow .12s; } .iwb-bg-swatch[data-bg="white"] { background: #fdfdfd; } .iwb-bg-swatch[data-bg="cyan"] { background: #e1eef0; } @@ -1828,7 +1828,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* 气泡上的「背景色」按钮:直接显示**当前背景色**的小色块(不再用调色板图标) */ .iwb-bg-dot { width: 16px; height: 16px; border-radius: 5px; padding: 0; pointer-events: none; flex: 0 0 auto; } .iwb-bg-dot.iwb-bg-swatch:hover { transform: none; } -.iwb-bg-palette-host { position: fixed; inset: 0; pointer-events: none; z-index: 3300; } +.iwb-bg-palette-host { position: fixed; inset: 0; pointer-events: none; z-index: var(--iwb-z-palette); } .iwb-bg-palette-host .iwb-pop-anchor { pointer-events: auto; } .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; } @@ -1883,8 +1883,8 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-plugin-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; } .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-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-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.38); display: flex; align-items: center; justify-content: center; z-index: var(--iwb-z-alert); } +.iwb-confirm-box { width: min(460px, calc(100vw - 48px)); background: var(--iwb-bg-menu); color: var(--iwb-text); border-radius: var(--iwb-radius-panel); padding: 18px 20px 14px; box-shadow: var(--iwb-elevation-3); } .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; } @@ -1980,7 +1980,7 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s .iwb-cpick-hex { font-variant-numeric: tabular-nums; } /* v3.25.75:去掉 mix-blend-mode(浅色底上文字糊成一团) */ .iwb-cpick-swatch::after { content: '▾'; margin-left: 6px; opacity: .7; font-size: 10px; } /* 提示可点开取色 */ .iwb-cpick-swatch { min-width: 104px; } -.iwb-cpick-pop { position: absolute; z-index: 80; top: calc(100% + 8px); left: 0; width: 236px; padding: 10px; border-radius: 10px; background: var(--iwb-panel); border: 1px solid var(--iwb-border); box-shadow: var(--sh-md); } +.iwb-cpick-pop { position: absolute; z-index: 80; top: calc(100% + 8px); left: 0; width: 236px; padding: 10px; border-radius: var(--iwb-radius-card); background: var(--iwb-panel); border: 1px solid var(--iwb-border); box-shadow: var(--iwb-elevation-2); } .iwb-cpick-box { position: relative; height: 132px; border-radius: 6px; cursor: crosshair; } .iwb-cpick-dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.4); pointer-events: none; } .iwb-cpick-hue { width: 100%; height: 12px; margin: 10px 0 8px; border-radius: 6px; -webkit-appearance: none; appearance: none; } @@ -2227,12 +2227,12 @@ html { scrollbar-width: thin; scrollbar-color: var(--iwb-border2) color-mix(in s /* 设置窗口可拖动(v3.25.76):拖标题栏移动,位置不受居中约束 */ .iwb-modal-draghead { cursor: move; user-select: none; } .iwb-modal-draghead:active { cursor: grabbing; } -.iwb-modal-floating { box-shadow: 0 24px 60px rgba(0,0,0,.32); } +.iwb-modal-floating { box-shadow: var(--iwb-elevation-4); } /* 设置面板专用透明遮罩(v3.25.77):去掉灰蒙层,调外观时能直接看到画布变化。 仍保留点击空白处关闭面板的行为。 */ .iwb-modal-mask.iwb-mask-ghost { background: transparent; } -.iwb-modal-mask.iwb-mask-ghost .iwb-settings-modal { box-shadow: 0 24px 60px rgba(0,0,0,.32); } +.iwb-modal-mask.iwb-mask-ghost .iwb-settings-modal { box-shadow: var(--iwb-elevation-4); } /* 自动配色开启时的提示行(v3.25.81) */ .iwb-appear-note-only { font-size: 12px; color: var(--iwb-text2); padding: 4px 0 0 2px; } diff --git a/tests/interface-hierarchy-test.js b/tests/interface-hierarchy-test.js index 179a5fd..a5bdcb9 100644 --- a/tests/interface-hierarchy-test.js +++ b/tests/interface-hierarchy-test.js @@ -16,7 +16,8 @@ const css = fs.readFileSync(path.join(__dirname, '..', 'style.css'), 'utf8') assert.ok(source.includes("shellView === 'home' ? el('div', { className: 'iwb-home-panel' }")) assert.ok(css.includes('.iwb-top-nav { height: 64px;')) assert.ok(!css.includes('.iwb-leftrail')) -assert.ok(css.includes('.iwb-fullmask { position: fixed; z-index: 260;')) +// M4-B2:全窗口面板的层级改由 token 表达(原裸值 260),顺序约束见 tests/overlay-layer-test.js +assert.ok(css.includes('.iwb-fullmask { position: fixed; z-index: var(--iwb-z-sheet);')) // v5 起画布在页面容器内,偏移由容器负责:这里钉住**最终生效**的 0 偏移(旧的 52/64 早已被 !important 覆盖) assert.ok(css.includes('.iwb-canvas, .ws-expanded .iwb-canvas { left: 0 !important; }')) assert.ok(css.includes('.iwb-canvas, .ws-expanded .iwb-canvas { top: 0 !important; }')) diff --git a/tests/overlay-layer-test.js b/tests/overlay-layer-test.js new file mode 100644 index 0000000..a8e569a --- /dev/null +++ b/tests/overlay-layer-test.js @@ -0,0 +1,75 @@ +// 浮层层级守卫(M4-B2) +// +// 为什么要有这个测试:z-index 是「没有类型、没有报错、错了只在特定操作顺序下露馅」的那类东西。 +// 迁移前 42 种裸值散在 2400 行 CSS 里,靠人肉比大小,出过两次真 bug: +// ① toast(200) < 弹窗(300) → 在弹窗/确认框里点「保存」,成功提示被盖住,用户以为没生效; +// ② 资源中心右键菜单(91) 被全窗口面板(260) 盖住 → 当时靠给这一个选择器打 270 补丁。 +// 现在层级只在 src/design-tokens.css(生成产物)里定义一次,组件引名字。本测试钉三件事: +// 1. 浮层族**不许再写裸数字**(防止回潮,M5 的 token-lint 会扩到全仓); +// 2. 引用的 --iwb-z-* 必须真的定义过(拼错名字时 z-index 变成无效声明,静默退化为 auto); +// 3. 四条顺序关系成立(见下面 INVARIANTS)。 + +const assert = require('assert') +const fs = require('fs') +const path = require('path') + +const ROOT = path.resolve(__dirname, '..') +const css = fs.readFileSync(path.join(ROOT, 'style.css'), 'utf8') +const tokens = fs.readFileSync(path.join(ROOT, 'src/design-tokens.css'), 'utf8') + +// 层级表(生成产物里的 --iwb-z-*) +const z = {} +for (const m of tokens.matchAll(/(--iwb-z-[a-z-]+)\s*:\s*(\d+)\s*;/g)) z[m[1]] = Number(m[2]) +assert.ok(Object.keys(z).length >= 10, '--iwb-z-* 层级表缺失或过短:' + Object.keys(z).join(', ')) + +// 1. 顺序关系。改数值前先想清楚这三条,测试只负责在你改错时喊停。 +const INVARIANTS = [ + ['toast 必须高于弹窗(弹窗里点保存要能看到提示)', '--iwb-z-toast', '--iwb-z-modal'], + ['弹窗必须高于全窗口面板', '--iwb-z-modal', '--iwb-z-sheet'], + ['面板内 portal 菜单要高于面板本身(否则被自己的容器盖住)', '--iwb-z-sheet-menu', '--iwb-z-sheet'], + ['面板内 portal 菜单不许越过弹窗(它是子菜单,不是新一层)', '--iwb-z-modal', '--iwb-z-sheet-menu'], + ['右键菜单高于右键遮罩(同一次点击里成对出现)', '--iwb-z-ctx-menu', '--iwb-z-ctx'], + ['右键菜单低于全窗口面板(面板开在菜单之上是正确方向)', '--iwb-z-sheet', '--iwb-z-ctx-menu'], + ['确认框/崩溃屏在最上层', '--iwb-z-alert', '--iwb-z-anchor'], + ['锚定浮层高于弹窗(外观面板挂在设置弹窗里)', '--iwb-z-anchor', '--iwb-z-modal'], + ['启动页高于弹窗(启动阶段不该被任何浮层穿透)', '--iwb-z-splash', '--iwb-z-modal'], +] +for (const [why, higher, lower] of INVARIANTS) { + assert.ok(z[higher] != null, '未定义:' + higher) + assert.ok(z[lower] != null, '未定义:' + lower) + assert.ok(z[higher] > z[lower], `${why}:${higher}(${z[higher]}) 必须 > ${lower}(${z[lower]})`) +} + +// 2. 浮层族的声明里不许出现裸数字 z-index。 +// 只查这 16 个选择器(它们构成「谁盖谁」的全部边界);画布内的端口/手柄是局部堆叠,不在此列。 +const OVERLAYS = [ + '.iwb-modal-mask', '.iwb-fullmask', '.iwb-command-mask', '.iwb-command', + '.iwb-ctxmask', '.iwb-ctxmenu', '.iwb-toast', '.iwb-pop-anchor', + '.iwb-ws-more', '.iwb-splash', '.iwb-imgpreview', '.iwb-crash-screen', + '.iwb-confirm-overlay', '.iwb-bg-palette-host', +] +const lines = css.split('\n') +for (const sel of OVERLAYS) { + for (const line of lines) { + if (!line.startsWith(sel + ' ') && !line.startsWith(sel + '{')) continue + const m = line.match(/z-index:\s*(-?\d+)/) + assert.ok(!m, `${sel} 还在写裸 z-index: ${m && m[1]},请改用 --iwb-z-*(层级表在 design-tokens.css)`) + } +} + +// 3. 引用的 z token 必须存在(拼错 → 声明无效 → 静默退化成 auto,最难查的一类) +for (const m of css.matchAll(/z-index:\s*var\((--iwb-z-[a-z-]+)\)/g)) { + assert.ok(z[m[1]] != null, '引用了不存在的层级 token:' + m[1]) +} + +// 4. toast 必须 portal 到 body —— 只改 CSS 数字治不好这条。 +// `.iwb-overlay` 自己带 z-index(100),是一个**堆叠上下文**:挂它里面的 toast 无论写多高, +// 整个子树都被封在 100 这一层里,压不过 portal 到 body 的弹窗(300)。这正是历史 bug +// 「弹窗里点保存看不到成功提示」的真正成因(2026-11-23 实测:改数字无效,portal 才有效)。 +const appSrc = fs.readFileSync(path.join(ROOT, 'app.js'), 'utf8') +assert.ok( + /ReactDOM\.createPortal\(el\('div', \{ className: 'iwb-toast/.test(appSrc), + 'toast 必须 ReactDOM.createPortal 到 document.body:.iwb-overlay 是堆叠上下文,内联渲染的 toast 永远压不过弹窗' +) + +console.log('overlay layer checks passed(层级表 ' + Object.keys(z).length + ' 档,' + INVARIANTS.length + ' 条顺序约束,toast portal 已钉)')