feat: AI 控制台会话化 + 视觉优化——①多轮对话连续性(后端 history 持久化 12 轮,Agent 注入历史上下文,DeepSeek 式会话:新建会话才清空);②聊天区改浅色(DeepSeek 风格,图片文字清晰);③截图点击放大查看
This commit is contained in:
@@ -96,6 +96,17 @@ function clearAgentChat(){
|
||||
document.getElementById('agent-chat').innerHTML =
|
||||
'<div class="agent-empty">对话已清空。给 AI 下达新指令…</div>';
|
||||
}
|
||||
// 新建会话:清后端历史 + 清前端对话区(像 DeepSeek 的新建会话)
|
||||
function newAgentSession(){
|
||||
if(_agentBusy){showToast('运行中不能新建会话','error');return;}
|
||||
if(!confirm('新建会话将清空当前对话历史,确定?'))return;
|
||||
apiPost('/api/agent/clear',{}).then(r=>{
|
||||
if(r&&r.ok){
|
||||
clearAgentChat();
|
||||
showToast('已新建会话','success');
|
||||
}else showToast('操作失败','error');
|
||||
});
|
||||
}
|
||||
|
||||
// ================== 发送与流式接收 ==================
|
||||
function sendAgentMsg(){
|
||||
@@ -188,6 +199,32 @@ function listenStream(runId){
|
||||
};
|
||||
}
|
||||
|
||||
// 截图点击放大查看
|
||||
function zoomScreenshot(img){
|
||||
const ov = document.getElementById('agent-zoom');
|
||||
if(!ov){
|
||||
const d = document.createElement('div');
|
||||
d.id = 'agent-zoom';
|
||||
d.style.cssText = 'display:none;position:fixed;inset:0;background:rgba(0,0,0,.8);z-index:1400;align-items:center;justify-content:center;cursor:zoom-out';
|
||||
d.onclick = ()=>d.style.display='none';
|
||||
document.body.appendChild(d);
|
||||
}
|
||||
const ovEl = document.getElementById('agent-zoom');
|
||||
ovEl.innerHTML = '';
|
||||
const big = document.createElement('img');
|
||||
big.src = img.src;
|
||||
big.style.cssText = 'max-width:88vw;max-height:88vh;border-radius:8px';
|
||||
ovEl.appendChild(big);
|
||||
ovEl.style.display = 'flex';
|
||||
}
|
||||
// 截图 img 绑定点击放大
|
||||
document.addEventListener('click', ev=>{
|
||||
const t = ev.target;
|
||||
if(t && t.tagName==='IMG' && t.closest('.agent-toolcard') && !t.closest('#agent-zoom')){
|
||||
zoomScreenshot(t);
|
||||
}
|
||||
});
|
||||
|
||||
function endRun(){
|
||||
_agentBusy = false;
|
||||
_agentStream && _agentStream.close();
|
||||
|
||||
Reference in New Issue
Block a user