Files
crawler-plugin/frontend-vue/tests/element-overlay-layering.test.ts
T
huangzd1997 a2ef06847a fix(admin-vue,app-web): 弹窗内下拉面板被自绘遮罩压住(去重台账分组下拉点开像空的)
Element 弹层 z-index 自 2000 递增,两站自绘浮层在 2600~3300(遮罩 3000、导出等待 3100、
更新门/铃铛面板 3200、铃铛日期面板 3300)。客户截图:去重数据汇总·新增导入 的分组下拉
点开什么都没有——选项面板被 .modal-mask(3000) 压在下面,不是数据为空(列表行分组列有值)。

- 后管 main.css:补 .el-popper{z-index:3500!important}(此前只抬过 ElMessage/消息盒,
  下拉面板漏了;铃铛日期面板是单独打补丁 .bell-date-popper{3300},说明只做过点修)。
- 用户端 main.css:popper/message/message-box 三条一起补(该站一条都没有),
  保持在同一个序里:popper 3500 < 消息 4000 < 消息盒 4100。
- 判据:后管 align-message-z-overlay.test.ts +1 支;用户端新增 element-overlay-layering.test.ts
  4 支,钉的是顺序不变式(popper<消息<消息盒、popper 高于 3300 档)而不是魔数。
- 棘轮基线点名:align-message-z-overlay 3/3/3→4/4/4,totals 1868/463/665→1869/464/666。

读数:后管 node --test 1966 绿 / vitest 253 绿 / vue-tsc rc=0;用户端 1163 绿 / vitest 156 绿 /
vue-tsc rc=0;反向刀(两处 popper 改回 2000)各红 1 支,逐字节复原后复绿;
_push_gate.py --fast overall=pass(9.5/8.8/9.8/9.6)。
2026-11-28 20:04:35 +08:00

62 lines
3.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import { fileURLToPath } from 'node:url'
import { dirname, join } from 'node:path'
/**
* 弹层层级:Element 弹层 z-index 自 2000 递增,低于本站自定义浮层(常驻警告/代理余量 3000、
* 更新门与铃铛面板 3200、铃铛日期面板 3300)。症状两种、同一根因:
* ① 浮层里的日期/下拉面板点开看不到(面板落在浮层背景之下);
* ② 浮层里触发的消息/确认框被压住(成本护栏 CostGuardAlert 的「继续任务」反馈)。
*
* 这条判据钉的不是某个数字,而是**不变式**:popper 高于全部自定义浮层、低于 ElMessage,
* ElMessage 低于消息盒。数字随便调,只要序还在就不会复现。
* 缺 !important 等于整条规则不生效——层级写在 Element 的内联 style 上,必须盖得住。
*/
const here = dirname(fileURLToPath(import.meta.url))
const ROOT = join(here, '..')
const read = (rel: string) => readFileSync(join(ROOT, rel), 'utf8').replace(/\r\n/g, '\n')
const mainCss = read('src/styles/main.css')
function zOf(selector: string): number {
const escaped = selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
const matched = mainCss.match(new RegExp(`${escaped}\\s*\\{[^}]*z-index:\\s*(\\d+)\\s*!important`))
assert.ok(matched, `${selector} 需带 !important 的 z-index(不盖内联层级会静默失效)`)
return Number(matched[1])
}
test('弹层抬升序:popper < ElMessage < 消息盒', () => {
const popper = zOf('.el-popper')
const message = zOf('.el-message')
const messageBox = zOf('.el-overlay.is-message-box')
assert.ok(popper < message, `popper(${popper}) 需低于 ElMessage(${message}),否则下拉会挡住提示`)
assert.ok(message < messageBox, `ElMessage(${message}) 需低于消息盒(${messageBox}),否则确认框被提示遮住`)
})
test('popper 高于本站全部自定义浮层(3000/3200/3300)', () => {
const popper = zOf('.el-popper')
assert.ok(popper > 3300, `popper(${popper}) 需高于铃铛日期面板等 3300 级浮层,否则浮层里的下拉/日历点开是空的`)
})
test('ElMessage 高于本站全部自定义浮层', () => {
const message = zOf('.el-message')
assert.ok(message > 3300, `ElMessage(${message}) 需高于 3000/3200 级浮层(成本护栏内触发的提示)`)
})
test('自定义浮层仍是已知的 3000/3200/3300 档(改了要同步本判据)', () => {
const overlays: Array<{ file: string; pattern: RegExp; expected: number }> = [
{ file: 'src/shared/components/CostGuardAlert.vue', pattern: /\.cost-guard-stack\s*\{[^}]*z-index:\s*(\d+)/, expected: 3000 },
{ file: 'src/shared/components/ProxyBalanceAlert.vue', pattern: /z-index:\s*(\d+)/, expected: 3000 },
{ file: 'src/shared/components/notification-bell.css', pattern: /z-index:\s*(\d+)/, expected: 3200 },
{ file: 'src/shared/components/notification-bell-popover.css', pattern: /\.bell-date-popper\s*\{[^}]*z-index:\s*(\d+)/, expected: 3300 },
]
for (const { file, pattern, expected } of overlays) {
const matched = read(file).match(pattern)
assert.ok(matched, `${file} 未找到浮层层级定义`)
assert.equal(Number(matched[1]), expected, `${file} 浮层层级变了:新档位需回看 main.css 的 3500/4000/4100 是否仍在其上`)
}
})