From f669e759d2a61eda5131d64ea79c5d74e6bef47b Mon Sep 17 00:00:00 2001 From: kicer Date: Thu, 3 Sep 2026 21:14:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E6=8A=BD=E5=B1=89=E6=A1=8C?= =?UTF-8?q?=E9=9D=A2=E7=AB=AF=20hover=20=E5=88=A0=E9=99=A4=E6=8C=89?= =?UTF-8?q?=E9=92=AE=20=E2=80=94=20=E9=BC=A0=E6=A0=87=E7=BB=8F=E8=BF=87?= =?UTF-8?q?=E8=A1=8C=E5=8F=B3=E4=BE=A7=E6=98=BE=E7=A4=BA=E5=9E=83=E5=9C=BE?= =?UTF-8?q?=E6=A1=B6,=E7=82=B9=E5=87=BB=E5=BC=B9=E5=88=A0=E9=99=A4=20modal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/server/public/css/style.css | 25 ++++++-------- app/server/public/index.html | 58 +++++++++------------------------ 2 files changed, 26 insertions(+), 57 deletions(-) diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index 0c6544e..4ec3ac1 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -465,23 +465,18 @@ footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0 width: 100%; } -/* 桌面端用的内联小 ×:默认隐藏,hover/focus 露出 */ -.conv-item .conv-del-inline { - display: none; - flex: none; width: 22px; height: 22px; border-radius: 50%; - background: transparent; border: 0; color: var(--gray-light); - font-size: 16px; line-height: 1; padding: 0; cursor: pointer; - align-items: center; justify-content: center; +/* 桌面端 hover 删除按钮:鼠标经过会话行时右侧显示,点击弹删除确认 modal + (触屏设备不显示,移动端删除仍走左滑手势) */ +.conv-del { + position: absolute; right: 8px; top: 50%; transform: translateY(-50%); + width: 24px; height: 24px; border-radius: 7px; + display: none; align-items: center; justify-content: center; + color: var(--gray); background: var(--surface); border: 1px solid var(--border); + z-index: 2; } @media (hover: hover) and (pointer: fine) { - /* 仅带精确指针(鼠标/触摸板)且能 hover 的设备才在行内露小 × - 触屏设备即使满足 (hover: hover) 也不命中,避免点按后持续 hover 露出 × */ - .conv-item .conv-del-inline { display: flex; } - .conv-item:hover .conv-del-inline, - .conv-item:focus-within .conv-del-inline, - .conv-item .conv-del-inline:focus { color: var(--ink); } - .conv-item .conv-del-inline:hover, - .conv-item .conv-del-inline:active { color: #fff; background: #c0392b; } + .conv-wrap:hover .conv-del { display: flex; } + .conv-del:hover { color: #c0392b; background: #fdf3f2; border-color: #eac2bd; } } .drawer-empty { padding: 24px 10px; font-size: 13px; color: var(--gray-light); text-align: center; } diff --git a/app/server/public/index.html b/app/server/public/index.html index ea70563..b4c50b1 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -680,7 +680,9 @@ html += '
' + '' + + '' + + '' + '
'; } @@ -1445,14 +1447,9 @@ searchTimer = setTimeout(loadSessionList, 250); }); $('drawer-list').addEventListener('click', e => { - if (e.target.closest('.conv-del-inline')) { - const wrap = e.target.closest('.conv-wrap'); - const item = wrap && wrap.querySelector('.conv-item'); - if (item) { deleteSession(item.dataset.id); collapseAllSwiped(); } - return; // 不打开会话 - } - // 点击后收起其他已滑开的行 - collapseAllSwiped(); + // 桌面端 hover 删除按钮:先于打开会话处理,点击弹删除确认 modal + const delBtn = e.target.closest('.conv-del'); + if (delBtn) { e.stopPropagation(); deleteSession(delBtn.dataset.del); return; } const item = e.target.closest('.conv-item'); if (!item) return; openSession(item.dataset.id); @@ -1460,13 +1457,6 @@ }); // ---------- 移动端右滑会话行露出删除按钮(iOS 风格) ---------- - function collapseAllSwiped(except) { - document.querySelectorAll('.conv-wrap.swiped').forEach(el => { - if (el === except) return; // 保留当前手势的行,避免自己滑回去时弹回 - el.classList.remove('swiped'); - const it = el.querySelector('.conv-item'); if (it) it.style.transform = ''; - }); - } (function bindSwipeToDelete() { const list = $('drawer-list'); const THRESHOLD = 60; // 滑过这个距离开 @@ -1479,7 +1469,7 @@ if (!item || !wrap) { g = null; return; } // 关闭 transform 动画,保证跟手不粘滞 item.style.transition = 'none'; - g = { x0: t.clientX, y0: t.clientY, t0: Date.now(), wrap, item, horiz: false, lastX: t.clientX, wasSwiped: wrap.classList.contains('swiped') }; + g = { x0: t.clientX, y0: t.clientY, t0: Date.now(), wrap, item, horiz: false, lastX: t.clientX }; } function onMove(e) { if (!g) return; @@ -1489,22 +1479,14 @@ // 先判断为横向手势才接管 if (!g.horiz) { if (Math.abs(dx) < 8 && Math.abs(dy) < 8) return; - if (Math.abs(dy) > Math.abs(dx) + 6) { g = null; restoreTrans(); return; } // 竖向滚动,不接管 + if (Math.abs(dy) > Math.abs(dx) + 6) { g = null; g.item.style.transition = ''; return; } // 竖向滚动,不接管 g.horiz = true; - // 横向识别:收起其他已滑开的行(自己保留) - collapseAllSwiped(g.wrap); } - // 统一 clamp 到 [-60, 0]:负值左滑出删除、正值表示右滑回去 - // 起手已 swiped 状态:基线是 -60 - const base = g.wasSwiped ? -60 : 0; - const off = Math.max(-60, Math.min(0, base + dx)); + // 跟手 clamp 到 [-60, 0]:负值左滑,正值右滑 + const off = Math.max(-60, Math.min(0, dx)); g.item.style.transform = 'translateX(' + off + 'px)'; g.lastX = t.clientX; } - function restoreTrans() { - // 还原 conv-item 的 transition,让后续 swipe 动作有弹回动画 - if (g && g.item) g.item.style.transition = ''; - } function onUp(e) { if (!g) return; const t = (e.changedTouches && e.changedTouches[0]) || null; @@ -1513,21 +1495,13 @@ // 恢复 transition(为 snap 提供动画) g.item.style.transition = ''; if (g.horiz) { - if (moved >= THRESHOLD) { - // 起手已是已滑开态 + 右滑回去:不应该触发删除,直接恢复原状 - if (g.wasSwiped && dx > 0) { - // 保持 swiped 状态(因为这是从 -60 滑回 -30 不到 0 的情况) - // 但本次手不是超阈值出去的,既然收回去就令弹回 - g.wrap.classList.remove('swiped'); - g.item.style.transform = ''; - } else { - // 滑到位:不露 conv-del,直接弹删除确认 modal - g.wrap.classList.remove('swiped'); - g.item.style.transform = ''; - deleteSession(g.item.dataset.id); - } + if (moved >= THRESHOLD && dx < 0) { + // 左滑到位:弹删除确认 modal(不露 conv-del) + g.wrap.classList.remove('swiped'); + g.item.style.transform = ''; + deleteSession(g.item.dataset.id); } else { - // 未达阈值:弹回 + // 右滑到位 或 未达阈值:弹回 g.wrap.classList.remove('swiped'); g.item.style.transform = ''; }