工具卡时间入折叠体、全屏查看自动展开并支持双指缩放

This commit is contained in:
2026-09-02 15:22:58 +08:00
parent 1c0fd5c909
commit ea6373846d
3 changed files with 36 additions and 8 deletions
+3 -1
View File
@@ -172,7 +172,7 @@ body {
#fs-body .msg-bubble { box-shadow: none; font-size: 15.5px; }
#fs-body .tool-card { max-width: 100%; }
#fs-body .tool-card pre { max-height: 65vh; }
#fs-viewer { position: fixed; inset: 0; z-index: 130; background: rgba(8,10,20,0.88); padding: 40px 14px 24px; overflow-y: auto; }
#fs-viewer { position: fixed; inset: 0; z-index: 130; background: rgba(8,10,20,0.88); padding: 40px 14px 24px; overflow: auto; /* 缩放后支持横纵滚动 */ }
#fs-viewer.hidden { display: none; }
.fs-panel { max-width: 860px; margin: 0 auto; background: #fff; border-radius: 14px; padding: 18px 20px; font-size: 15.5px; }
.fs-close {
@@ -196,6 +196,8 @@ body {
white-space: pre-wrap; overflow-x: auto; max-height: 300px; overflow-y: auto;
font-size: 12px; color: #55492a;
}
/* 时间行在折叠体内,展开才可见;作卡片尾注 */
.tool-card .tool-time { color: #b3a97f; margin-top: 6px; }
.tool-card.error { background: #fdecea; border-color: #f2c4bd; color: #a3352a; }
.tool-card .spin { display: inline-block; width: 1em; text-align: center; }
.tool-card .tool-args-full { color: #6b5b2a; }
+5 -5
View File
@@ -301,10 +301,10 @@
</div>
<!-- 发版时更新 v 参数,避免移动端浏览器缓存旧 JS -->
<script src="/js/core.js?v=20260902h"></script>
<script src="/js/tasks.js?v=20260902h"></script>
<script src="/js/skills.js?v=20260902h"></script>
<script src="/js/models.js?v=20260902h"></script>
<script src="/js/settings.js?v=20260902h"></script>
<script src="/js/core.js?v=20260902i"></script>
<script src="/js/tasks.js?v=20260902i"></script>
<script src="/js/skills.js?v=20260902i"></script>
<script src="/js/models.js?v=20260902i"></script>
<script src="/js/settings.js?v=20260902i"></script>
</body>
</html>
+28 -2
View File
@@ -318,8 +318,9 @@ function renderToolCard(id, name, argsStr, createdAt) {
'<span class="tool-name">' + esc(name) + '</span>' +
'<span class="tool-args">' + esc(toolArgsSummary(name, argsStr)) + '</span></summary>' +
'<pre class="tool-args-full">' + esc(toolArgsFull(argsStr)) + '</pre>' +
'<pre class="tool-result">执行中…</pre></details>' +
'<div class="msg-time tool-time">' + fmtTime(createdAt || Date.now()) + '</div>';
'<pre class="tool-result">执行中…</pre>' +
// 时间行/复制按钮在折叠体内:展开卡片才可见
'<div class="msg-time tool-time">' + fmtTime(createdAt || Date.now()) + '</div></details>';
return div;
}
@@ -633,10 +634,13 @@ const ui = {
openFullscreen(el) {
const body = $('fs-body');
body.innerHTML = '';
body.style.zoom = '';
// 深拷贝并去掉 id:保留原类名使气泡/工具卡样式在查看器内照常生效,且避免 id 重复
const clone = el.cloneNode(true);
clone.removeAttribute('id');
clone.querySelectorAll('[id]').forEach(function (n) { n.removeAttribute('id'); });
// 全屏查看直接展开参数/结果,方便观看
clone.querySelectorAll('details').forEach(function (d) { d.open = true; });
body.appendChild(clone);
$('fs-viewer').classList.remove('hidden');
},
@@ -862,6 +866,28 @@ document.getElementById('messages').addEventListener('dblclick', function (e) {
if (el) ui.openFullscreen(el);
});
// 全屏查看器双指缩放:页面 viewport 是 user-scalable=no(原生捏合被禁),
// 在查看器内接管双指手势,用 CSS zoom 缩放内容(1~4 倍,关闭时重置)。
(function () {
const viewer = document.getElementById('fs-viewer');
if (!viewer) return;
let startDist = 0, startZoom = 1, pinching = false;
const tdist = t => Math.hypot(t[0].clientX - t[1].clientX, t[0].clientY - t[1].clientY);
viewer.addEventListener('touchstart', function (e) {
if (e.touches.length !== 2) { pinching = false; return; }
pinching = true;
startDist = tdist(e.touches) || 1;
startZoom = Number($('fs-body').style.zoom) || 1;
}, { passive: true });
viewer.addEventListener('touchmove', function (e) {
if (!pinching || e.touches.length < 2) return;
e.preventDefault(); // 双指期间阻止滚动,手势归缩放
$('fs-body').style.zoom = Math.min(4, Math.max(1, startZoom * tdist(e.touches) / startDist)) || '';
}, { passive: false });
viewer.addEventListener('touchend', function (e) { if (e.touches.length < 2) pinching = false; }, { passive: true });
viewer.addEventListener('touchcancel', function () { pinching = false; }, { passive: true });
})();
// ---------- Tab 注册 ----------
window.tabModules = window.tabModules || {};
tabModules.tasks = {