diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css
index a42d1d5..773e0a0 100644
--- a/app/server/public/css/style.css
+++ b/app/server/public/css/style.css
@@ -360,10 +360,13 @@ footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0
width: 16px; height: 16px; flex-shrink: 0;
stroke: #7f8db0; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
+/* 长文件名:横向滚动查看全文(隐藏滚动条,靠 touch/Shift+滚轮/方向键滑动) */
.files-panel .file-name {
- flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
+ flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap;
font-weight: 500;
+ scrollbar-width: none; -ms-overflow-style: none;
}
+.files-panel .file-name::-webkit-scrollbar { display: none; }
.files-panel .file-size {
flex: none; background: var(--surface); color: var(--gray);
font-size: 11px; padding: 2px 8px; border-radius: 9px;
@@ -553,6 +556,9 @@ footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0
#fs-body .tool-card { max-width: 100%; }
#fs-body .tool-card pre { max-height: 65vh; }
+/* HTML 预览:沙箱 iframe 铺满全屏查看器 */
+.fs-html-frame { width: 100%; height: 100%; min-height: 70vh; border: 0; background: #fff; border-radius: 12px; }
+
/* ================= 设置区(覆盖层页面;卡片/表单样式搬自 style.css 适配 v2 变量) ================= */
#settings-page {
position: absolute; inset: 0; z-index: 60;
diff --git a/app/server/public/index.html b/app/server/public/index.html
index ad98ca1..5f572c3 100644
--- a/app/server/public/index.html
+++ b/app/server/public/index.html
@@ -431,9 +431,10 @@
const attach = p.files && p.files.length
? '
📎 ' + esc(p.files.join('、')) + '
' : '';
const r = mdHtml(p.text);
+ // 复制内容取纯文本(不含【系统通知】附件行),与气泡里显示一致
return '' +
'
' + attach + r.html + '
' +
- '
' + fmtTime(m.created_at) + '
' +
+ actionsHtml(m.created_at, p.text) +
'
';
}
@@ -571,7 +572,7 @@
const wrap = document.createElement('div');
wrap.className = 'msg me';
wrap.innerHTML = '' + attach + r.html + '
' +
- '' + fmtTime(Date.now()) + '
';
+ actionsHtml(Date.now(), content);
$('chat-view').appendChild(wrap);
scrollBottom();
}
@@ -1177,12 +1178,15 @@
return;
}
el.innerHTML = files.map(f => {
- const pv = /\.(md|txt)$/i.test(f.filename); // md/txt 支持单击预览
- // 可预览文件的行首图标用眼睛,与普通文件图标区分
- const ico = pv
- ? ''
- : '';
- return '' +
+ // 预览策略:md/txt/html 进 fs-viewer 预览;pdf/图片浏览器原生渲染更稳,转 blob URL 新标签页打开
+ const low = f.filename.toLowerCase();
+ const fsPv = /\.(md|txt|html?)$/.test(low);
+ const tabOpen = /\.(pdf|png|jpe?g|gif|webp|svg)$/.test(low);
+ let ico;
+ if (fsPv) ico = '
';
+ else if (tabOpen) ico = '
';
+ else ico = '
';
+ return '
' +
ico +
'
' + esc(String(f.filename).split('/').pop() || f.filename) + '' +
'
' + fmtSize(f.size) + '' +
@@ -1192,27 +1196,51 @@
}).join('');
} catch (e) { toast('读取文件失败:' + e.message); }
}
- // 单击可预览文件 → 与双击会话消息同一全屏预览窗(#fs-viewer):md 按 markdown 渲染,txt 保持原文排版
- async function previewTextFile(name) {
+ // 单击可预览文件 → 全屏预览(#fs-viewer):md 按 markdown 渲染、txt 原文排版、html 用沙箱 iframe
+ async function previewInFs(name) {
try {
const r = await fetch('/api/sessions/' + state.sessionId + '/files/download?path=' + encodeURIComponent(name));
if (r.status === 401) { location.href = '/login'; return; }
if (!r.ok) { let msg = 'HTTP ' + r.status; try { msg = (await r.json()).error || msg; } catch (_) {} throw new Error(msg); }
- const text = await r.text();
- let cls = 'bubble-ai', html;
- if (/\.md$/i.test(name)) {
- const r2 = mdHtml(text);
- html = r2.html;
- if (r2.fmt) cls += ' md';
+ if (/\.html?$/i.test(name)) {
+ const html = await r.text();
+ const body = $('fs-body');
+ body.innerHTML = '';
+ const iframe = document.createElement('iframe');
+ iframe.className = 'fs-html-frame';
+ iframe.setAttribute('sandbox', 'allow-same-origin allow-scripts');
+ iframe.srcdoc = html;
+ body.appendChild(iframe);
+ $('fs-viewer').classList.remove('hidden');
} else {
- html = esc(text);
+ const text = await r.text();
+ let cls = 'bubble-ai', html;
+ if (/\.md$/i.test(name)) {
+ const r2 = mdHtml(text);
+ html = r2.html;
+ if (r2.fmt) cls += ' md';
+ } else {
+ html = esc(text);
+ }
+ const wrap = document.createElement('div');
+ wrap.className = 'msg other';
+ wrap.innerHTML = '
' + html + '
';
+ openFullscreen(wrap.firstChild); // 复用双击气泡的全屏查看器
}
- const wrap = document.createElement('div');
- wrap.className = 'msg other';
- wrap.innerHTML = '
' + html + '
';
- openFullscreen(wrap.firstChild); // 复用双击气泡的全屏查看器
} catch (e) { toast('预览失败:' + e.message); }
}
+ // 单击 pdf/图片 → 浏览器原生渲染最稳;拉流走同源 cookie 鉴权,转 blob URL 后新标签页打开
+ async function openInTab(name) {
+ try {
+ const r = await fetch('/api/sessions/' + state.sessionId + '/files/download?path=' + encodeURIComponent(name));
+ if (r.status === 401) { location.href = '/login'; return; }
+ if (!r.ok) { let msg = 'HTTP ' + r.status; try { msg = (await r.json()).error || msg; } catch (_) {} throw new Error(msg); }
+ const blob = await r.blob();
+ const url = URL.createObjectURL(blob);
+ window.open(url, '_blank', 'noopener');
+ setTimeout(function () { URL.revokeObjectURL(url); }, 60 * 1000);
+ } catch (e) { toast('打开失败:' + e.message); }
+ }
async function downloadFile(name) {
if (!state.sessionId) return;
try {
@@ -1233,7 +1261,10 @@
const path = row.dataset.path;
if (!path) return;
if (e.target.closest('.del')) deleteFile(path);
- else if (e.target.closest('.file-row.clickable') && !e.target.closest('.file-act')) previewTextFile(path);
+ else if (e.target.closest('.file-row.clickable') && !e.target.closest('.file-act')) {
+ if (/\.(pdf|png|jpe?g|gif|webp|svg)$/i.test(path)) openInTab(path);
+ else previewInFs(path);
+ }
else if (e.target.closest('.file-act')) downloadFile(path);
});
// 面板内上传:直接写入当前会话任务目录