diff --git a/admin-frontend-vue/src/pages/account/UserSecretsPage.vue b/admin-frontend-vue/src/pages/account/UserSecretsPage.vue index e41a7ba94..735cc1b1d 100644 --- a/admin-frontend-vue/src/pages/account/UserSecretsPage.vue +++ b/admin-frontend-vue/src/pages/account/UserSecretsPage.vue @@ -287,7 +287,7 @@ onMounted(load) 状态 创建时间 更新时间 - 操作 + 操作 diff --git a/admin-frontend-vue/src/pages/asin/DedupeRegistryPage.vue b/admin-frontend-vue/src/pages/asin/DedupeRegistryPage.vue index cc8f6e020..1507f2d0d 100644 --- a/admin-frontend-vue/src/pages/asin/DedupeRegistryPage.vue +++ b/admin-frontend-vue/src/pages/asin/DedupeRegistryPage.vue @@ -390,7 +390,7 @@ onMounted(() => { 分组 创建时间 更新时间 - 操作 + 操作 diff --git a/admin-frontend-vue/src/pages/asin/QueryAsinPage.vue b/admin-frontend-vue/src/pages/asin/QueryAsinPage.vue index 42b093c70..0e090d067 100644 --- a/admin-frontend-vue/src/pages/asin/QueryAsinPage.vue +++ b/admin-frontend-vue/src/pages/asin/QueryAsinPage.vue @@ -405,7 +405,7 @@ onMounted(() => { 国家 创建时间 更新时间 - 操作 + 操作 @@ -723,6 +723,9 @@ h3 { justify-content: flex-end; gap: 8px; white-space: nowrap; + /* 与最低价 ASIN 同形:列宽已从 9% 改成 140px 下限,再补 wrap 兜住文案变长的情况, + 让"超宽"从"按钮静默消失"退化成"多占一行"。 */ + flex-wrap: wrap; background: #ffffff; box-shadow: -9px 0 12px -10px rgba(31, 48, 66, 0.45); } diff --git a/admin-frontend-vue/src/pages/asin/SkipPricePage.vue b/admin-frontend-vue/src/pages/asin/SkipPricePage.vue index d16440a45..10e0dcc5f 100644 --- a/admin-frontend-vue/src/pages/asin/SkipPricePage.vue +++ b/admin-frontend-vue/src/pages/asin/SkipPricePage.vue @@ -459,7 +459,7 @@ onMounted(() => { 最低价 创建时间 更新时间 - 操作 + 操作 @@ -805,6 +805,10 @@ h3 { justify-content: flex-end; gap: 8px; white-space: nowrap; + /* 列宽已从 9% 改成 140px 下限(两字按钮 53×2 + gap 8 + td 左右 padding 24 = 138)。 + 百分比会跟着容器一起缩,配上 justify-content:flex-end 后溢出翻到左侧, + "配置"整颗被吃掉而"删除"看着完好——2026-10-08 那单截图就是这个形状。 */ + flex-wrap: wrap; background: #ffffff; box-shadow: -9px 0 12px -10px rgba(31, 48, 66, 0.45); } diff --git a/admin-frontend-vue/src/pages/records/RecordsDigitalHumanVersionPage.vue b/admin-frontend-vue/src/pages/records/RecordsDigitalHumanVersionPage.vue index f11964fa1..6b6d8b540 100644 --- a/admin-frontend-vue/src/pages/records/RecordsDigitalHumanVersionPage.vue +++ b/admin-frontend-vue/src/pages/records/RecordsDigitalHumanVersionPage.vue @@ -225,7 +225,7 @@ onMounted(load) MD5 更新日志 发布时间 - 操作 + 操作 diff --git a/admin-frontend-vue/src/pages/shop/ShopKeysPage.vue b/admin-frontend-vue/src/pages/shop/ShopKeysPage.vue index f1888f0f4..817050e93 100644 --- a/admin-frontend-vue/src/pages/shop/ShopKeysPage.vue +++ b/admin-frontend-vue/src/pages/shop/ShopKeysPage.vue @@ -222,16 +222,18 @@ onMounted(load)
+ - - - - - - - - - + + + + + + + + + diff --git a/admin-frontend-vue/tests/ops-cell-must-wrap.test.ts b/admin-frontend-vue/tests/ops-cell-must-wrap.test.ts index 935fc7a26..f929ffd69 100644 --- a/admin-frontend-vue/tests/ops-cell-must-wrap.test.ts +++ b/admin-frontend-vue/tests/ops-cell-must-wrap.test.ts @@ -6,15 +6,47 @@ import { readSource } from './helpers.ts' /** * 操作列的按钮一旦超过列宽,会**整颗消失**而不是换行:这些页的 td 是 `overflow:hidden` + - * `table-layout:fixed`,而 `.ops-cell` 是 nowrap flex。2026-10-08 店铺密钥那单"没有删除功能" - * 就是这么来的——按钮在线上包的 DOM 里、事件也在,只是被裁到看不见点不到(列给 160px、实测需 240px)。 + * `table-layout:fixed`,而 `.ops-cell` / `.asin-col-actions` 是 nowrap flex。2026-10-08 店铺密钥 + * 那单"没有删除功能"就是这么来的——按钮在线上包的 DOM 里、事件也在,只是被裁到看不见点不到 + * (列给 160px、实测需 215.5px)。 * - * 这条看守钉的是**结构**不是像素:宽度按当前文案够,改天多一颗按钮或文案变长就又塌了, - * 而 `flex-wrap: wrap` 让"超宽"从"静默消失"退化成"多占一行",不需要有人去重算宽度。 + * 两条失败方向都见过: + * - 列宽写死 px(店铺密钥 160)⇒ 从**右**裁,最后一颗(删除)整颗没了; + * - 列宽写百分比(最低价 ASIN `9%`)⇒ 百分比跟着容器一起缩,且 `.asin-col-actions` 带 + * `justify-content: flex-end`,溢出翻到**左**侧,于是"配置"被吃掉、"删除"看着完好。 + * 所以光补 `flex-wrap` 不够:900px 容器下 9% 只有 56.7px,连一颗 53px 的按钮加 24px padding + * 都装不下,wrap 之后照样裁。列必须有 **px 下限**。 + * + * 下面 OPS_MIN_COL_PX 是实测不是估算:browser-use 在 100% 缩放下渲染 `.btn.btn-sm` 量的 + * offsetWidth(两字 53 / 四字 80 / 五字 93.5),加 `gap: 8px` 与 td 左右 padding 各 12px。 + * 三元文案按**较长**分支计(`检测中…` vs `检测白名单` 取后者)。 */ const SRC = 'src/pages' +/** 每页操作列「单行装下全部按钮」所需的列最小宽(px,实测算出)。 */ +const OPS_MIN_COL_PX: Record = { + 'src/pages/account/CompaniesPage.vue': 77, + 'src/pages/account/GroupsPage.vue': 138, + 'src/pages/account/MenusPage.vue': 138, + 'src/pages/account/UserSecretsPage.vue': 314, + 'src/pages/account/UsersPage.vue': 138, + 'src/pages/asin/AsinInvalidPage.vue': 138, + 'src/pages/asin/DedupeRegistryPage.vue': 138, + 'src/pages/asin/ProductCategoryPage.vue': 138, + 'src/pages/asin/QueryAsinPage.vue': 138, + 'src/pages/asin/SkipPricePage.vue': 138, + 'src/pages/records/DeviceLogsPage.vue': 138, + 'src/pages/records/RecordsDigitalHumanVersionPage.vue': 287, + 'src/pages/records/RecordsSoftwareVersionPage.vue': 77, + 'src/pages/records/RecordsTutorialPage.vue': 77, + 'src/pages/shop/ShopKeysPage.vue': 240, + 'src/pages/shop/ShopManagePage.vue': 199, +} + +/** 操作列的 flex 容器类名。漏一个就是把一整族页面留在盲区里(`.asin-col-actions` 曾这么漏过两页)。 */ +const OPS_CELL_CLASSES = ['ops-cell', 'asin-col-actions'] + function vueFiles(dir: string): string[] { const out: string[] = [] for (const name of readdirSync(dir)) { @@ -25,6 +57,11 @@ function vueFiles(dir: string): string[] { return out } +/** 相对工程根的正斜杠路径。 */ +function rel(file: string): string { + return file.replace(/\\/g, '/') +} + interface Cell { file: string buttons: number @@ -35,32 +72,133 @@ interface Cell { function opsCells(sources: Array<{ file: string; source: string }>): Cell[] { const cells: Cell[] = [] for (const { file, source } of sources) { - const block = /\.ops-cell[ \t]*\{([^}]*)\}/.exec(source) - if (!block) continue - const td = /]*class="[^"]*ops[^"]*"[^>]*>([\s\S]*?)<\/td>/.exec(source) - const buttons = td ? (td[1].match(/` 一起吃掉;HTML 注释里出现"操作"就会把 + * 匹配范围截在第一个真 ', + ' ', + ' ', + ' ', + ' ', + ' ', + '', + ].join('\n') + assert.equal(opsColDecl(withCommentTrap), '245px', + '注释里的"操作"把匹配截在第一个真 '), null, + ''), '9%', + '百分比必须原样报出来,由调用方判成违规') + assert.equal(opsColDecl(''), '__no_header__', + '找不到「操作」表头要显式报,不能回 null 与"没声明"混成一类') + + const wrapOnlyInComment = [ + '', + '', + ].join('\n') + const cells = opsCells([{ file: 'src/pages/asin/TrapPage.vue', source: wrapOnlyInComment }]) + assert.equal(cells.length, 1, '假源码没被认出容器 ⇒ 扫描形状与源码脱节') + assert.equal(cells[0].buttons, 2, `按钮数应认出 2,实际 ${cells[0].buttons}`) + assert.equal(cells[0].wrapped, false, + 'CSS 注释里的 flex-wrap: wrap; 被当成了真声明 ⇒ 这条看守对"只写在注释里"的修复恒绿') +})
序号备注名紫鸟账号名称紫鸟令牌代理白名单状态 创建时间修改时间操作序号备注名紫鸟账号名称紫鸟令牌代理白名单状态 创建时间修改时间操作
宽度声明:返回 null = 压根没声明,返回 '9%' 这类 = 非 px。 + * 两处坑都踩过:`]*>` 会连 `
之前,于是把"序号 52px"当成操作列宽度报出来。 + */ +function opsColDecl(source: string): string | null { + const cleaned = stripHtmlComments(source) + const m = /]*)>(?:(?!<\/th>)[\s\S])*?操作(?:(?!<\/th>)[\s\S])*?<\/th>/.exec(cleaned) + if (!m) return '__no_header__' + const style = /style="[^"]*width:\s*([^;"]+)/.exec(m[1]) + return style ? style[1].trim() : null +} + +function sourcesOfAll(): Array<{ file: string; source: string }> { + return vueFiles(SRC).map((file) => ({ file, source: readSource(file) })) +} + +test('ops_ruler_actually_sees_the_family', () => { assert.ok(existsSync(SRC), `扫不到 ${SRC}:目录挪了就是整面恒绿`) - const cells = opsCells(vueFiles(SRC).map((file) => ({ file, source: readSource(file) }))) - assert.ok(cells.length >= 14, - `只认出 ${cells.length} 个带 .ops-cell 的页(今天 14 个)⇒ 扫描形状与源码脱节,这条看守已经失明`) + const cells = opsCells(sourcesOfAll()) + assert.ok(cells.length >= Object.keys(OPS_MIN_COL_PX).length, + `只认出 ${cells.length} 个操作列容器,登记表有 ${Object.keys(OPS_MIN_COL_PX).length} 页` + + ' ⇒ 扫描形状与源码脱节,下面的断言已经失明') const multi = cells.filter((c) => c.buttons >= 2) - assert.ok(multi.length >= 11, - `只认出 ${multi.length} 页操作列有 ≥2 颗按钮(今天 11 页)⇒ 按钮计数读不到,下面的断言无从判定`) + assert.ok(multi.length >= 13, + `只认出 ${multi.length} 页操作列有 ≥2 颗按钮(今天 13 页)⇒ 按钮计数读不到,无从判定`) +}) + +test('ops_cell_registry_matches_scanned_files_both_ways', () => { + const scanned = new Set(opsCells(sourcesOfAll()).map((c) => c.file)) + const registered = new Set(Object.keys(OPS_MIN_COL_PX)) + const unregistered = [...scanned].filter((f) => !registered.has(f)) + const vanished = [...registered].filter((f) => !scanned.has(f)) + assert.deepEqual(unregistered, [], + '这些页有操作列但没登记列宽下限 ⇒ 新增页面必须显式登记,否则这条看守对它无效') + assert.deepEqual(vanished, [], + '登记表里这些页已经扫不到了 ⇒ 页面删了要同步删表项,不许留死条目') }) test('every_multi_button_ops_cell_wraps', () => { - const offenders = opsCells(vueFiles(SRC).map((file) => ({ file, source: readSource(file) }))) + const offenders = opsCells(sourcesOfAll()) .filter((c) => c.buttons >= 2 && !c.wrapped) .map((c) => `${c.file}(${c.buttons} 颗按钮)`) assert.deepEqual(offenders, [], '这些页的操作列是 nowrap flex + td overflow:hidden:按钮总宽一旦超过列宽,' + '最后一颗会整颗被裁掉(看不见也点不到),补一行 flex-wrap: wrap 即可') }) + +test('ops_column_width_is_px_and_wide_enough', () => { const bad: string[] = [] + for (const [file, minPx] of Object.entries(OPS_MIN_COL_PX)) { + const decl = opsColDecl(readSource(file)) + if (decl === '__no_header__') { bad.push(`${file} 找不到「操作」列表头`); continue } + if (decl === null) { bad.push(`${file} 操作列 没声明宽度(fixed layout 下拿剩余空间,可被压到 0)`); continue } + const px = /^(\d+(?:\.\d+)?)px$/.exec(decl) + if (!px) { bad.push(`${file} 操作列声明 ${decl}:百分比会跟着容器缩,缩到装不下按钮就从左侧静默裁切`); continue } + if (parseFloat(px[1]) < minPx) { + bad.push(`${file} 操作列 ${px[1]}px < 实测需 ${minPx}px(按钮占宽 + gap + 左右 padding 24)`) + } + } + assert.deepEqual(bad, [], '操作列必须是 px 且 ≥ 实测需求,否则超宽时的失败模式是"按钮静默消失"') +}) + +/** + * 尺子自己得可证伪:下面四份内存假源码各对应一种"会判错"的形状, + * 判不出来就是恒绿——本仓在"注释喂饱判据"和"`` 一起吃"上各踩过一次。 + */ +test('ruler_is_falsifiable_on_in_memory_counterexamples', () => { + const withCommentTrap = [ + '
序号操作
之前 ⇒ 会把"序号"的宽度当成操作列宽度') + + assert.equal(opsColDecl('
操作
没写 style 时必须报 null,不能悄悄放过') + assert.equal(opsColDecl('
操作
别的列