Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c4076ba13 | ||
|
|
65d05d2656 | ||
|
|
e50015cdc1 |
@@ -1015,22 +1015,26 @@ body.voice-active .scroll-bottom-btn { display: none; }
|
||||
}
|
||||
.conv-item {
|
||||
position: relative;
|
||||
transition: background .12s;
|
||||
transition: background .12s, padding-right .12s;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 桌面端 hover 删除按钮:鼠标经过会话行时右侧显示,点击弹删除确认 modal
|
||||
(触屏设备不显示,移动端删除仍走左滑手势) */
|
||||
.conv-del {
|
||||
position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
|
||||
/* 桌面端 hover 行内按钮:右侧两个并排(新窗口 / 删除),触屏设备不显示(移动端删除走左滑手势) */
|
||||
.conv-pop, .conv-del {
|
||||
position: absolute; 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;
|
||||
}
|
||||
.conv-pop { right: 36px; }
|
||||
.conv-del { right: 8px; }
|
||||
@media (hover: hover) and (pointer: fine) {
|
||||
.conv-wrap:hover .conv-item:not(.active) { background: #f5f6f8; }
|
||||
.conv-wrap:hover .conv-del { display: flex; }
|
||||
/* hover 时标题让出右侧按钮位,防两个按钮压住文字 */
|
||||
.conv-wrap:hover .conv-item { padding-right: 68px; }
|
||||
.conv-wrap:hover .conv-pop, .conv-wrap:hover .conv-del { display: flex; }
|
||||
.conv-pop:hover { color: var(--active); background: var(--active-soft); border-color: currentColor; }
|
||||
.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; }
|
||||
|
||||
@@ -1093,7 +1093,15 @@
|
||||
searchTimer = setTimeout(loadSessionList, 250);
|
||||
});
|
||||
$('drawer-list').addEventListener('click', e => {
|
||||
// 桌面端 hover 删除按钮:先于打开会话处理,点击弹删除确认 modal
|
||||
// 桌面端 hover 行内按钮:先于打开会话处理
|
||||
const popBtn = e.target.closest('.conv-pop');
|
||||
if (popBtn) {
|
||||
e.stopPropagation();
|
||||
// files=1 让新窗口开局直接把侧栏切到文件树(打开后即被 syncUrl 抹掉)
|
||||
window.open('/?s=' + encodeURIComponent(popBtn.dataset.pop) + '&files=1', '_blank', 'noopener');
|
||||
return;
|
||||
}
|
||||
// 删除按钮:点击弹删除确认 modal
|
||||
const delBtn = e.target.closest('.conv-del');
|
||||
if (delBtn) { e.stopPropagation(); deleteSession(delBtn.dataset.del); return; }
|
||||
const item = e.target.closest('.conv-item');
|
||||
@@ -1251,6 +1259,8 @@
|
||||
if (!changed) return;
|
||||
if (files) window.showFileTree();
|
||||
else loadSessionList();
|
||||
// 地址栏跟着侧栏模式走(?s=<id>&files=1):刷新后还停在同一面板
|
||||
if (typeof syncUrl === 'function') syncUrl();
|
||||
}
|
||||
$('da-files').addEventListener('click', () => {
|
||||
setDrawerPane(!$('drawer').classList.contains('drawer-mode-files'));
|
||||
|
||||
@@ -31,6 +31,9 @@
|
||||
'<button class="conv-item' + (s.id === state.sessionId ? ' active' : '') + '" data-id="' + esc(s.id) + '">' +
|
||||
'<span class="conv-title">' + esc(s.title || s.id) + '</span>' + drawerStatusDot(s) +
|
||||
'</button>' +
|
||||
'<button class="conv-pop" data-pop="' + esc(s.id) + '" title="在新窗口打开" aria-label="在新窗口打开">' +
|
||||
'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>' +
|
||||
'</button>' +
|
||||
'<button class="conv-del" data-del="' + esc(s.id) + '" title="删除会话" aria-label="删除会话">' +
|
||||
'<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg>' +
|
||||
'</button>' +
|
||||
@@ -90,6 +93,7 @@
|
||||
state.renderedSigs = {};
|
||||
state.streaming = false;
|
||||
if (typeof clearEditState === 'function') clearEditState();
|
||||
syncUrl();
|
||||
setView('welcome'); // 复用 newChat 同样的视图切换路径
|
||||
}
|
||||
toast('已删除会话');
|
||||
@@ -184,6 +188,18 @@
|
||||
if (Date.now() - state.lastSseAt > 45000) probeSseAlive();
|
||||
});
|
||||
|
||||
// 地址栏跟随当前会话与侧栏模式:?s=<id>[&files=1],刷新/收藏/分享都能回到同一屏
|
||||
function syncUrl() {
|
||||
const id = state.sessionId;
|
||||
let url = '/';
|
||||
if (id) {
|
||||
url = '/?s=' + encodeURIComponent(id);
|
||||
// 侧栏停在文件树时带上 files=1:刷新后还是文件树,不会莫名退回会话列表
|
||||
if ($('drawer').classList.contains('drawer-mode-files')) url += '&files=1';
|
||||
}
|
||||
try { history.replaceState(null, '', url); } catch (_) {}
|
||||
}
|
||||
|
||||
async function openSession(id) {
|
||||
closeStream();
|
||||
removeTyping();
|
||||
@@ -228,8 +244,15 @@
|
||||
$('deep-think-btn').classList.toggle('on', state.deepThink);
|
||||
connectStream();
|
||||
if (window.refreshFileTree) window.refreshFileTree();
|
||||
syncUrl(); // 详情拿到才写地址栏:坏链接不会把刷新后的页面也钉死在坏会话上
|
||||
} catch (e) {
|
||||
if (state.sessionId === id) toast('打开会话失败:' + e.message);
|
||||
if (state.sessionId === id) {
|
||||
toast('打开会话失败:' + e.message);
|
||||
state.sessionId = null;
|
||||
state.sessionTitle = '';
|
||||
syncUrl();
|
||||
setView('welcome'); // 会话已被删/链接失效:别把「加载中…」留在屏幕上(同时把顶部按钮置灰)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,6 +270,7 @@
|
||||
renderHeader();
|
||||
updateHeaderActions();
|
||||
connectStream();
|
||||
syncUrl();
|
||||
return s.id;
|
||||
}
|
||||
|
||||
@@ -321,6 +345,7 @@
|
||||
userPaused = false;
|
||||
renderAttachChips();
|
||||
clearUploadCards();
|
||||
syncUrl();
|
||||
setView('welcome');
|
||||
$('chat-view').innerHTML = '';
|
||||
$('msg-input').value = '';
|
||||
|
||||
@@ -2085,11 +2085,15 @@
|
||||
loadSessionList();
|
||||
// 侧栏底部已是纯图标操作栏(不展示用户信息),不再需要 loadDrawerUser
|
||||
// 会话深链 /?s=<session_id>:数据页面(/app/{task_id}/...)的「返回会话」FAB 用——
|
||||
// task_id 即会话 id(engine 里 1:1),启动时消费一次即 replaceState 抹掉参数,
|
||||
// 避免刷新/分享时被钉回该会话;会话已删则 openSession 自行报错,落在 welcome。
|
||||
const deep = new URLSearchParams(location.search).get('s');
|
||||
// task_id 即会话 id(engine 里 1:1)。地址栏常驻 ?s= 不抹掉,刷新/收藏/分享都能回到同一会话;
|
||||
// 会话已删时 openSession 会自己回落到 welcome 并把 URL 清回 /。
|
||||
const params = new URLSearchParams(location.search);
|
||||
const deep = params.get('s');
|
||||
if (deep) {
|
||||
history.replaceState(null, '', '/');
|
||||
openSession(deep);
|
||||
openSession(deep).then(() => {
|
||||
// 从侧栏「在新窗口打开」进来(带 files=1):开局直接把侧栏切到文件树;
|
||||
// 窄屏/无会话/文件树未加载时 setDrawerPane 内部会自行忽略
|
||||
if (params.get('files') === '1' && typeof setDrawerPane === 'function') setDrawerPane(true);
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user