fix(style-source): 修面板在真实宿主里被撑宽裁切 + 容器尺寸兜底
- 根因:.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,卡片图片/名称全部正常
This commit is contained in:
1 parent
38a34ff533
commit
98f66ccaf8
2 files changed
+27
-2
No files matched your search
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user