前端四处修复:工具卡片 spin 图标去掉转圈动画(完成后直接显示 ✓/✕);展开工具卡片时新增 tool-args-full 块完整展示调用参数(pretty JSON),结果填入独立的 tool-result 块;消息气泡内 ul/ol 恢复缩进与外边距,圆点不再溢出 msg-bubble;删除会话改为单个弹窗(内含默认不勾选的【同时删除任务目录】),取消两次 confirm
This commit is contained in:
@@ -128,6 +128,8 @@ body {
|
||||
.msg-bubble table { border-collapse: collapse; margin: 6px 0; display: block; overflow-x: auto; }
|
||||
.msg-bubble th, .msg-bubble td { border: 1px solid #dde; padding: 4px 8px; font-size: 13px; }
|
||||
.msg-bubble blockquote { border-left: 3px solid #ccd; padding-left: 8px; color: #667; margin: 4px 0; }
|
||||
.msg-bubble ul, .msg-bubble ol { padding-left: 1.5em; margin: 6px 0; }
|
||||
.msg-bubble li { margin: 2px 0; }
|
||||
.msg-time { font-size: 10px; color: #aab; margin-top: 3px; }
|
||||
|
||||
/* 工具卡片 */
|
||||
@@ -146,8 +148,8 @@ body {
|
||||
font-size: 12px; color: #55492a;
|
||||
}
|
||||
.tool-card.error { background: #fdecea; border-color: #f2c4bd; color: #a3352a; }
|
||||
.tool-card .spin { display: inline-block; animation: rot 1s linear infinite; }
|
||||
@keyframes rot { to { transform: rotate(360deg); } }
|
||||
.tool-card .spin { display: inline-block; width: 1em; text-align: center; }
|
||||
.tool-card .tool-args-full { color: #6b5b2a; }
|
||||
|
||||
/* ---- 文件面板 ---- */
|
||||
.files-panel {
|
||||
@@ -227,6 +229,22 @@ body {
|
||||
font-size: 15px; font-weight: 600; cursor: pointer;
|
||||
}
|
||||
.primary-btn:active { opacity: 0.9; }
|
||||
.ghost-btn {
|
||||
flex: 1; background: #f2f3f7; color: #445; border: 1px solid #dde;
|
||||
border-radius: 10px; padding: 11px; font-size: 15px; cursor: pointer;
|
||||
}
|
||||
.ghost-btn:active { background: #e8eaf0; }
|
||||
.btn-row { display: flex; gap: 10px; }
|
||||
.btn-row .primary-btn { flex: 1; }
|
||||
.modal .modal-text { font-size: 14px; color: #556; margin-bottom: 12px; }
|
||||
.modal .del-dir {
|
||||
display: flex; align-items: center; gap: 7px;
|
||||
font-size: 14px; color: #334; margin-bottom: 14px; cursor: pointer;
|
||||
}
|
||||
.modal .del-dir input {
|
||||
width: 16px; height: 16px; padding: 0; margin: 0; flex-shrink: 0;
|
||||
accent-color: #c33;
|
||||
}
|
||||
|
||||
/* ---- Toast ---- */
|
||||
.toast {
|
||||
|
||||
@@ -93,6 +93,19 @@
|
||||
<button class="primary-btn" onclick="ui.createSession()">创建</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 删除会话弹窗 -->
|
||||
<div id="delete-modal" class="modal-overlay hidden" onclick="if(event.target===this)ui.closeDelete()">
|
||||
<div class="modal">
|
||||
<h3>删除会话</h3>
|
||||
<div class="modal-text" id="delete-modal-text">确定删除该会话?</div>
|
||||
<label class="del-dir"><input type="checkbox" id="del-dir-check">同时删除任务目录(文件将不可恢复)</label>
|
||||
<div class="btn-row">
|
||||
<button class="ghost-btn" onclick="ui.closeDelete()">取消</button>
|
||||
<button class="primary-btn" style="background:linear-gradient(135deg,#a3352a,#d2483c);" onclick="ui.confirmDelete()">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast hidden" id="toast"></div>
|
||||
|
||||
@@ -15,6 +15,7 @@ const state = {
|
||||
streamText: '',
|
||||
toolCards: {},
|
||||
filePanelOpen: false,
|
||||
pendingDeleteId: null,
|
||||
};
|
||||
|
||||
// ---------- API ----------
|
||||
@@ -69,6 +70,10 @@ function toolArgsSummary(name, argsStr) {
|
||||
if (s.length > 80) s = s.slice(0, 80) + '…';
|
||||
return s;
|
||||
}
|
||||
function toolArgsFull(argsStr) {
|
||||
try { return JSON.stringify(JSON.parse(argsStr || '{}'), null, 2); }
|
||||
catch (_) { return argsStr || ''; }
|
||||
}
|
||||
|
||||
// ---------- 页面切换 ----------
|
||||
function showChat() {
|
||||
@@ -151,7 +156,8 @@ function renderToolCard(id, name, argsStr) {
|
||||
'<details><summary><span class="spin">◌</span>' +
|
||||
'<span class="tool-name">' + esc(name) + '</span>' +
|
||||
'<span class="tool-args">' + esc(toolArgsSummary(name, argsStr)) + '</span></summary>' +
|
||||
'<pre>执行中…</pre></details>';
|
||||
'<pre class="tool-args-full">' + esc(toolArgsFull(argsStr)) + '</pre>' +
|
||||
'<pre class="tool-result">执行中…</pre></details>';
|
||||
return div;
|
||||
}
|
||||
|
||||
@@ -160,7 +166,8 @@ function fillToolResult(id, content, isError) {
|
||||
if (!card) return;
|
||||
if (isError) card.classList.add('error');
|
||||
card.querySelector('.spin').textContent = isError ? '✕' : '✓';
|
||||
card.querySelector('pre').textContent = content || '(空)';
|
||||
const pre = card.querySelector('.tool-result');
|
||||
if (pre) pre.textContent = content || '(空)';
|
||||
}
|
||||
|
||||
function msgNode(m, cardMap) {
|
||||
@@ -360,9 +367,21 @@ const ui = {
|
||||
this.openSession(s.id);
|
||||
} catch (e) { toast('创建失败:' + e.message); }
|
||||
},
|
||||
async deleteSession(id) {
|
||||
if (!confirm('删除会话?')) return;
|
||||
const delDir = confirm('同时删除任务目录(文件将不可恢复)?\n取消 = 仅删除会话记录');
|
||||
deleteSession(id) {
|
||||
state.pendingDeleteId = id;
|
||||
$('del-dir-check').checked = false;
|
||||
$('delete-modal-text').textContent = '确定删除会话 ' + id + '?';
|
||||
$('delete-modal').classList.remove('hidden');
|
||||
},
|
||||
closeDelete() {
|
||||
$('delete-modal').classList.add('hidden');
|
||||
state.pendingDeleteId = null;
|
||||
},
|
||||
async confirmDelete() {
|
||||
const id = state.pendingDeleteId;
|
||||
if (!id) return;
|
||||
const delDir = $('del-dir-check').checked;
|
||||
this.closeDelete();
|
||||
try {
|
||||
await req('DELETE', '/api/sessions/' + id + '?delete_dir=' + (delDir ? 'true' : 'false'));
|
||||
if (state.sessionId === id) this.backToList();
|
||||
|
||||
Reference in New Issue
Block a user