fix(ui): 边缘细条在 DS Bot 全屏页不可见 (v0.5.3-local.12)

现象:DS Bot 全屏页里工作台入口(左缘细条)看不到,切回经典布局才可见。

1. 层级:细条 z-index 65 被宿主全屏页容器盖住 → 提到 2147483000,
   面板 2147483001;细条默认底色与右边框对比度提高。
2. fixed 包含块:祖先带 transform / perspective / filter / contain 时,
   position: fixed 的参照系从视口变成该祖先,细条整体偏移甚至移出可视区。
   新增 fixedOrigin() 测出包含块原点,edgeLeft 换算为相对坐标,
   并夹到 [0, 视口宽-12];无常规侧栏时贴包含块左缘。
3. 自诊断:挂载 800ms 后细条宽高为 0 时 console.warn 输出左侧位置与
   最多 8 层祖先的 display / transform,便于定位宿主槽位被隐藏的情况。

验证:npm run pack 全绿(含 edge-panel 4 组回归),双资产同源 6a18b101…。
This commit is contained in:
wangheng
2026-12-03 16:17:46 +08:00
parent 5cca08d3bb
commit 6bffa6477e
8 changed files with 132 additions and 23 deletions
+58 -3
View File
@@ -1248,6 +1248,7 @@ function WorktableSection(props: any) {
// 细条常驻左缘;hover 展开面板,移开延迟 180ms 收回(防抖动);
// 任何弹窗打开期间保持展开;「自动隐藏」关掉后常开,可手动点 « 收成细条。
const [edgeLeft, setEdgeLeft] = useState(64)
const stripRef = useRef<HTMLDivElement | null>(null)
const [edgeOpen, setEdgeOpen] = useState(false)
const [edgeDismissed, setEdgeDismissed] = useState(false)
const edgeCloseTimer = useRef<number | null>(null)
@@ -1627,10 +1628,37 @@ function WorktableSection(props: any) {
// dockWidth = sidebar 宽 − paddingLeft − paddingRight − 40(每边内缩 20)
// left = sidebar 左边缘视口坐标 + paddingLeft + 20
// 降级:找不到 sidebar 或宽度 ≤0 → left 固定 14px,宽度不设内联(交 CSS min/max 处理)
/**
* position:fixed 的包含块原点。
* 任何祖先带 transform / perspective / filter / contain(paint|layout|strict|content)
* 都会把 fixed 的参照系从视口改成该祖先 —— DS Bot 等全屏页面常带 transform,
* 直接用视口坐标会让细条和面板整体偏移甚至移出可视区。
* 这里返回该包含块的实际原点(视口坐标),供调用方把期望坐标换算成相对值。
*/
const fixedOrigin = useCallback((): { left: number; top: number } => {
let el: HTMLElement | null = rootRef.current?.parentElement ?? null
while (el && el !== document.body && el !== document.documentElement) {
const cs = getComputedStyle(el)
const transform = cs.transform && cs.transform !== 'none'
const perspective = cs.perspective && cs.perspective !== 'none'
const filter = cs.filter && cs.filter !== 'none'
const contain = /paint|layout|strict|content/i.test(cs.contain || '')
if (transform || perspective || filter || contain) {
const r = el.getBoundingClientRect()
return { left: r.left + el.scrollLeft, top: r.top + el.scrollTop }
}
el = el.parentElement
}
return { left: 0, top: 0 }
}, [])
const measureFloatGeo = useCallback(() => {
const origin = fixedOrigin()
const sidebar = findSidebar(rootRef.current)
if (!sidebar) {
// 宿主没有常规侧栏(如 DS Bot 全屏页):细条贴包含块左缘,保证入口可见
setFloatGeo({ left: 14, width: null })
setEdgeLeft(Math.round(Math.max(0, -origin.left)))
return
}
const rect = sidebar.getBoundingClientRect()
@@ -1643,24 +1671,30 @@ function WorktableSection(props: any) {
// 细条贴左缘:优先从 footerActions/footArea 容器实测左缘 − 栏内边距 8;
// 链断裂时回退实测侧栏左缘(webview 内浅色栏左缘即原生 rail 右缘,xiaoquai 为 0)。
// 旧兜底 64 会在隐藏态留出 64px 残带。
// 结果再减去 fixed 包含块原点,换算成相对定位祖先的坐标。
setEdgeLeft((() => {
let el: HTMLElement | null = rootRef.current
let viewportLeft: number | null = null
while (el) {
if (typeof el.className === 'string' && /footerActions|footArea/i.test(el.className)) {
const r = el.getBoundingClientRect()
if (r.width > 120) return Math.max(0, Math.round(r.left) - 8)
if (r.width > 120) { viewportLeft = Math.round(r.left) - 8; break }
break
}
el = el.parentElement
}
return Math.max(0, Math.round(rect.left))
const base = viewportLeft ?? Math.round(rect.left)
const relative = base - Math.round(origin.left)
// 夹到 [0, 视口宽 - 12]:定位祖先尺寸异常时不至于把细条推出可视区
const maxLeft = Math.max(0, (typeof window !== 'undefined' ? window.innerWidth : 1280) - 12)
return Math.min(maxLeft, Math.max(0, relative))
})())
if (width > 0) {
setFloatGeo({ left: Math.round(rect.left + padLeft + margin), width: Math.round(width) })
} else {
setFloatGeo({ left: 14, width: null })
}
}, [])
}, [fixedOrigin])
useLayoutEffect(() => {
measureFloatGeo()
@@ -2627,6 +2661,26 @@ function buildCustomLayoutPrompt(req: string): string {
const anyPopupOpen = addOpen || viewOptionsOpen || customOpen || requestDelete != null
|| iconPick != null || bindPick != null || viewPickFor != null || consoleBind != null
// 边缘面板可见性自诊断:宿主把 footer 槽位 display:none / 祖先带 transform 时,
// fixed 细条可能整块不渲染。只在不可见时 warn 一次,便于现场定位。
useEffect(() => {
const id = window.setTimeout(() => {
const el = stripRef.current
if (!el) return
const r = el.getBoundingClientRect()
if (r.width > 0 && r.height > 0) return
let chain: string[] = []
let node: HTMLElement | null = el.parentElement
while (node && node !== document.body && chain.length < 8) {
const cs = getComputedStyle(node)
chain.push(node.tagName.toLowerCase() + '.' + (node.className || '') + ':display=' + cs.display + ',transform=' + cs.transform)
node = node.parentElement
}
console.warn('[dsh-worktable] 边缘细条不可见(宽高为 0 或被隐藏)', { left: el.style.left, rect: { w: r.width, h: r.height }, chain })
}, 800)
return () => window.clearTimeout(id)
}, [])
/** 自动隐藏模式看 hover 状态;常开模式看是否被手动收起 */
const edgeVisible = view.edgeAutoHide === false ? !edgeDismissed : (edgeOpen || anyPopupOpen)
@@ -3466,6 +3520,7 @@ function buildCustomLayoutPrompt(req: string): string {
<>
<div ref={rootRef} className="dsh-wt_section dsh-wt_edgeAnchor" style={dockedStyle} aria-hidden />
<div
ref={stripRef}
className={'dsh-wt_edgeStrip' + (edgeVisible ? ' dsh-wt_edgeStripOn' : '')}
style={{ left: edgeLeft }}
role="button"
+2 -2
View File
@@ -681,10 +681,10 @@ export const css = xtermCss + '\n' + [
'.dsh-wt_manageRowSub{margin-left:20px}',
// 停靠态:左缘细条 + 滑出面板
'.dsh-wt_edgeAnchor{width:0;height:0;overflow:hidden;flex:none}',
'.dsh-wt_edgeStrip{position:fixed;top:0;bottom:0;width:12px;z-index:65;display:flex;align-items:center;justify-content:center;cursor:pointer;background:var(--dsw-alias-fill-l1,rgba(125,125,125,.07));border-right:1px solid transparent;transition:background .15s,border-color .15s}',
'.dsh-wt_edgeStrip{position:fixed;top:0;bottom:0;width:12px;z-index:2147483000;display:flex;align-items:center;justify-content:center;cursor:pointer;background:var(--dsw-alias-fill-l1,rgba(125,125,125,.14));border-right:1px solid var(--dsw-alias-border-l1,rgba(125,125,125,.18));transition:background .15s,border-color .15s}',
'.dsh-wt_edgeStrip:hover,.dsh-wt_edgeStripOn{background:var(--dsw-alias-fill-l1,rgba(255,255,255,.05));border-right-color:var(--dsw-alias-border-l1,#262b36)}',
'.dsh-wt_edgeStripGlyph{font-size:11px;line-height:1;color:var(--dsw-alias-label-tertiary,#6e7683);user-select:none;-webkit-user-select:none}',
'.dsh-wt_edgePanelWrap{position:fixed;top:0;bottom:0;width:250px;z-index:66;transform:translateX(-100%);transition:transform .18s ease;box-shadow:14px 0 30px rgba(0,0,0,.18)}',
'.dsh-wt_edgePanelWrap{position:fixed;top:0;bottom:0;width:250px;z-index:2147483001;transform:translateX(-100%);transition:transform .18s ease;box-shadow:14px 0 30px rgba(0,0,0,.18)}',
'.dsh-wt_edgePanelWrapOn{transform:translateX(0)}',
'.dsh-wt_edgePanel{position:absolute;inset:0;box-sizing:border-box;padding:10px 10px 14px;background:var(--dsw-alias-bg-base,#0b0e14);border-right:1px solid var(--dsw-alias-border-l2,#3a4150);overflow-y:auto;overscroll-behavior:contain}',
'.dsh-wt_edgeHandle{position:absolute;right:0;top:50%;transform:translateY(-50%);width:17px;height:64px;display:flex;align-items:center;justify-content:center;padding:0;border:1px solid var(--dsw-alias-border-l2,#3a4150);border-right:none;border-radius:8px 0 0 8px;background:var(--dsw-alias-fill-l1,rgba(125,125,125,.10));color:var(--dsw-alias-state-accent-primary,#4f8ef7);font-size:13px;line-height:1;cursor:pointer;box-shadow:-4px 0 10px rgba(0,0,0,.14)}',