From e89b825d34c5af5a2eaa31600c87672b28158c46 Mon Sep 17 00:00:00 2001 From: kicer Date: Thu, 3 Sep 2026 16:41:45 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20index.html=20=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E9=9D=A2=E6=9D=BF=E4=B8=8E=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E5=8C=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 附件按钮移到右侧发送按钮旁,两钮间留间距 - 任务文件列表删除按钮文案 删→删除 - 上传图标改为带圆圈背景色的上传图标,更醒目 - md 文件支持单击预览,复用会话双击的全屏查看器(#fs-viewer) - 任务文件列表样式对齐技能文件列表(文件图标/虚线分隔/胶囊大小标签/填充动作按钮) --- app/server/public/css/style.css | 37 +++++++++++++++++++++---------- app/server/public/index.html | 39 ++++++++++++++++++++++++--------- 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index cbc1894..e160b4c 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -266,7 +266,7 @@ footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0 gap: 6px; padding-top: 6px; } -/* 左右侧栏等宽,保证中部的附件按钮位于整行几何中心 */ +/* 左右侧栏:左侧放开关,右侧放附件+发送(gap 拉开两钮间距) */ .ia-side { flex: 1 1 0; min-width: 0; @@ -274,7 +274,7 @@ footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0 align-items: center; } .ia-left { justify-content: flex-start; } -.ia-right { justify-content: flex-end; } +.ia-right { justify-content: flex-end; gap: 12px; } /* 深度思考开关(左侧功能开关) */ .think-toggle { @@ -340,29 +340,42 @@ footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0 .files-panel-header .file-upload { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; - color: var(--gray); cursor: pointer; + background: var(--active-soft); color: var(--active); cursor: pointer; } -.files-panel-header .file-upload:active { background: var(--surface); } +.files-panel-header .file-upload:active { background: var(--active); color: #fff; } .files-panel-header .file-upload svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; } -.files-panel .files-list { overflow-y: auto; padding: 4px; } +.files-panel .files-list { overflow-y: auto; padding: 4px 6px; } .files-panel .file-row { - display: flex; align-items: center; gap: 10px; - padding: 8px 10px; border-radius: 10px; font-size: 13.5px; + display: flex; align-items: center; gap: 8px; + padding: 8px; border-radius: 8px; font-size: 13.5px; cursor: default; + border-bottom: 1px dashed var(--border); } +.files-panel .file-row:last-child { border-bottom: none; } .files-panel .file-row:active { background: var(--surface); } +.files-panel .file-row.clickable { cursor: pointer; } /* md 文件:整行可点预览 */ +.files-panel .file-ico { + width: 16px; height: 16px; flex-shrink: 0; + stroke: #7f8db0; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; +} .files-panel .file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; + font-weight: 500; +} +.files-panel .file-size { + flex: none; background: var(--surface); color: var(--gray); + font-size: 11px; padding: 2px 8px; border-radius: 9px; } -.files-panel .file-size { flex: none; color: var(--gray-light); font-size: 12px; } .files-panel .file-act { - flex: none; color: var(--active); font-size: 13px; padding: 3px 8px; border-radius: 7px; + flex: none; background: var(--active-soft); color: var(--active); + border: none; border-radius: 7px; padding: 4px 9px; font-size: 13px; cursor: pointer; } -.files-panel .file-act:active { background: var(--active-soft); } -.files-panel .file-act.del { color: #c0392b; } -.files-panel .file-act.del:active { background: #fdecea; } +.files-panel .file-act:active { opacity: .75; } +.files-panel .file-act.view { background: var(--surface); color: var(--ink); } +.files-panel .file-act.del { background: #fdecea; color: #c0392b; } +.files-panel .file-act.del:active { opacity: .75; } .files-panel .empty-tip { padding: 20px 10px; text-align: center; font-size: 13px; color: var(--gray-light); } diff --git a/app/server/public/index.html b/app/server/public/index.html index e876000..b00f247 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -71,10 +71,10 @@ 深度思考 -
+ @@ -108,14 +108,14 @@
- +
任务文件
@@ -1146,7 +1146,7 @@ toast(state.deepThink ? '深度思考已开启(暂不影响后端)' : '深度思考已关闭'); }); - // ---------- 任务文件面板(底部浮层:点输入行中部的附件按钮展开,遮罩盖住输入区) ---------- + // ---------- 任务文件面板(底部浮层:点输入行右侧发送旁的附件按钮展开,遮罩盖住输入区) ---------- function setFilesPanel(open) { const panel = $('files-panel'); if (open) { @@ -1176,15 +1176,33 @@ el.innerHTML = '
还没有文件,在对话框上传或让 AI 生成
'; return; } - el.innerHTML = files.map(f => - '
' + + el.innerHTML = files.map(f => { + const isMd = /\.md$/i.test(f.filename); + return '
' + + '' + '' + esc(String(f.filename).split('/').pop() || f.filename) + '' + '' + fmtSize(f.size) + '' + + (isMd ? '' : '') + '' + - '' + - '
').join(''); + '' + + '
'; + }).join(''); } catch (e) { toast('读取文件失败:' + e.message); } } + // 单击 md 文件 → 与双击会话消息同一全屏预览窗(#fs-viewer):拉取文本、markdown 渲染后预览 + async function previewMdFile(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(); + const r2 = mdHtml(text); + const wrap = document.createElement('div'); + wrap.className = 'msg other'; + wrap.innerHTML = '
' + r2.html + '
'; + openFullscreen(wrap.firstChild); // 复用双击气泡的全屏查看器 + } catch (e) { toast('预览失败:' + e.message); } + } async function downloadFile(name) { if (!state.sessionId) return; try { @@ -1205,6 +1223,7 @@ const path = row.dataset.path; if (!path) return; if (e.target.closest('.del')) deleteFile(path); + else if (e.target.closest('.view') || (e.target.closest('.file-row.clickable') && !e.target.closest('.file-act'))) previewMdFile(path); else if (e.target.closest('.file-act')) downloadFile(path); }); // 面板内上传:直接写入当前会话任务目录