From 98f66ccaf839c7ea1921f2cd2d0f3c4e87a31200 Mon Sep 17 00:00:00 2001 From: qiqi Date: Mon, 2 Nov 2026 09:24:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(style-source):=20=E4=BF=AE=E9=9D=A2?= =?UTF-8?q?=E6=9D=BF=E5=9C=A8=E7=9C=9F=E5=AE=9E=E5=AE=BF=E4=B8=BB=E9=87=8C?= =?UTF-8?q?=E8=A2=AB=E6=92=91=E5=AE=BD=E8=A3=81=E5=88=87=20+=20=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=B0=BA=E5=AF=B8=E5=85=9C=E5=BA=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 根因:.iwb-full-panel-plugin 是裸 div(宿主无样式),flex 子项 min-width 默认 auto, 13 个分类 chip 单行不换行的 max-content 约 955px,把容器顶到 955, 资源中心窗口只有 918 ⇒ 搜索框/刷新按钮/chips 尾巴/状态栏全被裁在右边 - mount 时给容器补 min-width:0 + min-height:0 + height:100% + overflow:hidden (只给收缩许可,不写 flex:1 —— 资源中心是 flex row、侧栏是 flex column,语义不同) - chips 自身再加 min-width:0 / max-width:100% 双保险 - harness 加两条「无水平溢出」断言(窄档/宽档),host 不再预置 min-width:0 以真实复现 - 真实站点复验:容器 918 = 面板 918,overflowX=0,卡片图片/名称全部正常 --- style-source/src/index.js | 12 ++++++++++++ style-source/tools/harness.mjs | 17 +++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/style-source/src/index.js b/style-source/src/index.js index b53bbd6..e2a008e 100644 --- a/style-source/src/index.js +++ b/style-source/src/index.js @@ -136,6 +136,8 @@ .iwb-ss-chips { flex: 0 0 auto; display: flex; gap: 4px; padding: 0 10px 7px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; + /* 13 个 chip 不换行 ⇒ max-content 近 950px。不夹住会让祖先容器按固有宽度撑开 */ + min-width: 0; max-width: 100%; } .iwb-ss-chips::-webkit-scrollbar { display: none; } .iwb-ss-chip { @@ -430,6 +432,16 @@ ensureStyle() host.innerHTML = '' + // ⚠️ 宿主给的面板容器 .iwb-full-panel-plugin 是裸 div,没任何样式,flex 子项的 min-width 默认 auto。 + // 分类 chips 是单行不换行(13 个),它的 max-content 约 950px,会把容器顶到 950, + // 资源中心窗口只有 680 左右 ⇒ 搜索框、chips 尾巴、状态栏全被裁在右边。 + // 补上 min-width:0 允许收缩 + flex:1 填满剩余,插件根才有正确的宽度可依。 + // 只给「可收缩」许可,不设 flex 宽度/方向:容器在不同宿主位置(资源中心 flex row / 侧栏 flex column)语义不同, + // 写死 flex:1 会在固定宽度的侧栏里被拉满整个父容器。 + host.style.minWidth = '0' + host.style.minHeight = '0' + host.style.height = '100%' + host.style.overflow = 'hidden' const ui = { root: null, search: null, chips: null, grid: null, detail: null, status: null, toastEl: null, diff --git a/style-source/tools/harness.mjs b/style-source/tools/harness.mjs index 3d6ce59..fb755cc 100644 --- a/style-source/tools/harness.mjs +++ b/style-source/tools/harness.mjs @@ -150,7 +150,7 @@ async function main() { const stage = document.getElementById('stage') const host = document.createElement('div') host.id = 'hostA' - host.style.cssText = 'width:320px;height:640px;display:flex;min-width:0' + host.style.cssText = 'width:320px;height:640px' stage.appendChild(host) panel.mount(host) window.__hostA = host @@ -185,6 +185,13 @@ async function main() { 'card=' + geom.cardH + ' img=' + geom.imgH) check('卡片名称可见', geom.nameH >= 10 && geom.name.length > 0, geom.name + ' / h=' + geom.nameH) + // 回归守门:13 个 chip 不换行,max-content 近 950px,要把祖先容器顶宽(真实宿主窗口只有 680,右侧全被裁) + const ov1 = await page.evaluate(() => { + const r = document.querySelector('#hostA .iwb-ss-root') + return { sw: r.scrollWidth, cw: r.clientWidth } + }) + check('窄档无水平溢出(chip max-content 不顶宽容器)', ov1.sw <= ov1.cw + 1, 'scrollW=' + ov1.sw + ' clientW=' + ov1.cw) + // ---- 默认窄档 ---- const layoutNarrow = await page.evaluate(() => window.__hostA.querySelector('.iwb-ss-root').getAttribute('data-layout')) check('320px 初始为 narrow', layoutNarrow === 'narrow', String(layoutNarrow)) @@ -255,6 +262,12 @@ async function main() { check('宽档详情占比约 46%', wideDetail.ratio > 0.3 && wideDetail.ratio < 0.5, wideDetail.ratio.toFixed(2)) check('宽档网格列数增加', wideDetail.cols >= 4, 'cols=' + wideDetail.cols) + const ov2 = await page.evaluate(() => { + const r = document.querySelector('#hostA .iwb-ss-root') + return { sw: r.scrollWidth, cw: r.clientWidth } + }) + check('宽档无水平溢出', ov2.sw <= ov2.cw + 1, 'scrollW=' + ov2.sw + ' clientW=' + ov2.cw) + // ---- 恢复窄档,测边界:479/480 ---- await page.evaluate(() => { window.__hostA.style.width = '479px' }) const at479 = await poll(async () => { @@ -303,7 +316,7 @@ async function main() { const stage = document.getElementById('stage') const hostB = document.createElement('div') hostB.id = 'hostB' - hostB.style.cssText = 'width:920px;height:600px;display:flex;min-width:0' + hostB.style.cssText = 'width:920px;height:600px' stage.appendChild(hostB) window.__calls.panels[0].mount(hostB) window.__hostB = hostB