diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index 2c2e05b..1dbc77b 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -1656,9 +1656,13 @@ label.icon-btn { cursor: pointer; } /* ---------- preview pane v2: drag resize / info card / plain text ---------- */ /* 拖拽调宽的手柄:预览在左半侧,所以手柄在它的右缘(与会话列的分界) */ -.pv-resizer { position: absolute; right: 0; top: 0; bottom: 0; width: 6px; cursor: col-resize; z-index: 6; touch-action: none; } -.pv-resizer:hover, .pv-resizer:active { background: var(--active); opacity: .3; } +.pv-resizer { position: absolute; right: 0; top: 0; bottom: 0; width: 10px; cursor: col-resize; z-index: 6; touch-action: none; } +.pv-resizer:hover, .pv-resizer:active { background: var(--active); opacity: .25; } body.pv-resizing { cursor: col-resize; user-select: none; } +/* 拖动期间把重排/重绘圈在各自列里:会话列宽度跟着变,不 contain 就是整页重排 */ +body.pv-resizing #app { pointer-events: none; } +body.pv-resizing #chat-view { contain: paint; } +body.pv-resizing #pv-pane { contain: layout paint; } body.pv-resizing #pv-pane iframe { pointer-events: none; } .pv-plain { width: 100%; } .pv-pre { width: 100%; max-width: 920px; margin: 0 auto; padding: 14px 20px 40px; font: 12.5px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; } diff --git a/app/server/public/js/preview.js b/app/server/public/js/preview.js index 63c9c5c..fa84970 100644 --- a/app/server/public/js/preview.js +++ b/app/server/public/js/preview.js @@ -789,21 +789,31 @@ window.matchMedia('(min-width: 960px)').addEventListener('change', () => { if (! const h = document.createElement('div'); h.className = 'pv-resizer'; pane.appendChild(h); - let st = null; + let st = null; // { x: 起始 clientX, w: 起始宽度, lastX: 最新 clientX } + let rafId = 0; + // 改 --pv-w 会带着 #app 的 width/margin 一起重排(会话里的文字跟着重新折行), + // 一帧可能来十几个 pointermove,所以只在 rAF 里落一次值。 + function commit() { + if (!st) return; + document.documentElement.style.setProperty('--pv-w', clamp(st.w + (st.lastX - st.x)) + 'px'); + } h.addEventListener('pointerdown', (e) => { - st = { x: e.clientX, w: pane.offsetWidth || clamp(window.innerWidth * 0.5) }; + e.preventDefault(); // 从按下这一刻就掐掉拖选,否则会顺手选中一大片消息文字 + st = { x: e.clientX, w: pane.offsetWidth || clamp(window.innerWidth * 0.5), lastX: e.clientX }; try { h.setPointerCapture(e.pointerId); } catch (_) {} document.body.classList.add('pv-resizing'); }); h.addEventListener('pointermove', (e) => { if (!st) return; - document.documentElement.style.setProperty('--pv-w', clamp(st.w + (e.clientX - st.x)) + 'px'); + st.lastX = e.clientX; + if (!rafId) rafId = requestAnimationFrame(() => { rafId = 0; commit(); }); }); function end() { if (!st) return; + if (rafId) { cancelAnimationFrame(rafId); rafId = 0; commit(); } // 把最后一帧补上 + const w = pane.offsetWidth; st = null; document.body.classList.remove('pv-resizing'); - const w = pane.offsetWidth; if (w) localStorage.setItem('pv-w', String(w)); } h.addEventListener('pointerup', end);