From 1c982d160fc006355c0aa60843510a90cadd1bae Mon Sep 17 00:00:00 2001 From: kicer Date: Thu, 3 Sep 2026 19:53:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E6=8A=BD=E5=B1=89=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E8=A1=8C=E5=8A=A0=E5=88=A0=E9=99=A4=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - conv-item 右侧加 × 按钮(hover/focus-within 露出,移动端常显微透明) - 点击 × 走 confirmModal(默认含任务目录 delete_dir=true,和 v1 modal 一致) - 删的是当前打开的会话:closeStream + 清状态 + setView('welcome') - 成功 toast + loadSessionList 刷新 --- app/server/public/css/style.css | 15 +++++++++++++++ app/server/public/index.html | 29 ++++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index 8f74544..58b0b0f 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -445,6 +445,21 @@ footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0 .conv-item .st-dot.queued { background: var(--active); } .conv-item .st-dot.active { background: #1c7a2e; animation: pill-pulse 1.2s ease-in-out infinite; } .conv-item .st-dot.held { background: #b8860b; } +/* 会话行内的删除 ×:默认隐藏,hover/focus-within/active 露出,点击变红 */ +.conv-item .conv-del { + flex: none; width: 22px; height: 22px; border-radius: 50%; + display: flex; align-items: center; justify-content: center; + background: transparent; border: 0; color: var(--gray-light); + font-size: 16px; line-height: 1; padding: 0; cursor: pointer; + opacity: 0; transition: opacity .12s, color .12s, background .12s; +} +.conv-item:hover .conv-del, .conv-item:focus-within .conv-del, .conv-item .conv-del:focus { opacity: 1; } +.conv-item .conv-del:hover, .conv-item .conv-del:active { color: #fff; background: #c0392b; } +/* 移动端无 hover:用 :focus-within/active 也能在点会话名字时短暂高亮行,但为了看不见的×也可见, + 在抽屉打开状态下始终让 × 微透明(以不影响未 hover 行的整洁) */ +@media (hover: none) { + .conv-item .conv-del { opacity: .45; } +} .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 41dbb70..1db0681 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -678,6 +678,7 @@ if (g !== lastGroup) { html += '
' + esc(g) + '
'; lastGroup = g; } html += '' + ''; } box.innerHTML = html; @@ -702,7 +703,28 @@ } catch (e) { toast('加载会话失败:' + e.message); } } - // ---------- 会话打开 / 新建 / 状态栏(删除会话入口已移除,改用状态栏「清空/终止/选择模型」) ---------- + // ---------- 会话打开 / 新建 / 状态栏(抽屉行 × 调 deleteSession; 默认含任务目录) ---------- + async function deleteSession(id) { + if (!id) return; + if (!await confirmModal('删除会话', '确定删除会话 ' + id + ' ?会话中的任务文件也会一起删除。', '删除', true)) return; + try { + await req('DELETE', '/api/sessions/' + id + '?delete_dir=true'); + // 删的是当前打开的会话:回 welcome 视图并清状态 + if (state.sessionId === id) { + closeStream(); + removeTyping(); + state.sessionId = null; + state.sessionTitle = ''; + state.streamEl = null; + state.streamText = ''; + state.toolCards = {}; + state.streaming = false; + setView('welcome'); // 复用 newChat 同样的视图切换路径 + } + toast('已删除会话'); + loadSessionList(); + } catch (e) { toast('删除失败:' + e.message); } + } function closeStream() { if (state.es) { state.es.close(); state.es = null; } } @@ -1417,6 +1439,11 @@ searchTimer = setTimeout(loadSessionList, 250); }); $('drawer-list').addEventListener('click', e => { + if (e.target.closest('.conv-del')) { + const item = e.target.closest('.conv-item'); + if (item) deleteSession(item.dataset.id); + return; // 不打开会话 + } const item = e.target.closest('.conv-item'); if (!item) return; openSession(item.dataset.id);