优化:新建会话页点文件按钮自动创建会话再弹文件面板,失败时提示原因

This commit is contained in:
2026-09-08 09:19:09 +08:00
parent 54aa56fefd
commit e1666fe93d
+15 -2
View File
@@ -1817,10 +1817,23 @@
$('files-mask').classList.toggle('show', open); $('files-mask').classList.toggle('show', open);
$('attach-btn').classList.toggle('active', open); $('attach-btn').classList.toggle('active', open);
} }
function toggleFilesPanel() { let ensuringSessionForFiles = false; // 防止建会话请求发出前重复点击按钮导致连建两个会话
async function toggleFilesPanel() {
const panel = $('files-panel'); const panel = $('files-panel');
const open = !panel.classList.contains('open'); const open = !panel.classList.contains('open');
if (open && !state.sessionId) { toast('先发送一条消息创建会话,再管理任务文件'); return; } if (open && !state.sessionId) {
// 新建会话页直接管理文件:自动建档会话再弹面板;建会话失败(如无可用模型)给出提示
if (ensuringSessionForFiles) return;
ensuringSessionForFiles = true;
try {
await ensureSession();
} catch (e) {
toast('创建会话失败:' + e.message);
return;
} finally {
ensuringSessionForFiles = false;
}
}
setFilesPanel(open); setFilesPanel(open);
} }
$('attach-btn').addEventListener('click', toggleFilesPanel); $('attach-btn').addEventListener('click', toggleFilesPanel);