feat(ui): index.html 任务文件面板与输入区优化
- 附件按钮移到右侧发送按钮旁,两钮间留间距 - 任务文件列表删除按钮文案 删→删除 - 上传图标改为带圆圈背景色的上传图标,更醒目 - md 文件支持单击预览,复用会话双击的全屏查看器(#fs-viewer) - 任务文件列表样式对齐技能文件列表(文件图标/虚线分隔/胶囊大小标签/填充动作按钮)
This commit is contained in:
@@ -266,7 +266,7 @@ footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0
|
|||||||
gap: 6px;
|
gap: 6px;
|
||||||
padding-top: 6px;
|
padding-top: 6px;
|
||||||
}
|
}
|
||||||
/* 左右侧栏等宽,保证中部的附件按钮位于整行几何中心 */
|
/* 左右侧栏:左侧放开关,右侧放附件+发送(gap 拉开两钮间距) */
|
||||||
.ia-side {
|
.ia-side {
|
||||||
flex: 1 1 0;
|
flex: 1 1 0;
|
||||||
min-width: 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;
|
align-items: center;
|
||||||
}
|
}
|
||||||
.ia-left { justify-content: flex-start; }
|
.ia-left { justify-content: flex-start; }
|
||||||
.ia-right { justify-content: flex-end; }
|
.ia-right { justify-content: flex-end; gap: 12px; }
|
||||||
|
|
||||||
/* 深度思考开关(左侧功能开关) */
|
/* 深度思考开关(左侧功能开关) */
|
||||||
.think-toggle {
|
.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 {
|
.files-panel-header .file-upload {
|
||||||
width: 30px; height: 30px; border-radius: 50%;
|
width: 30px; height: 30px; border-radius: 50%;
|
||||||
display: flex; align-items: center; justify-content: center;
|
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 {
|
.files-panel-header .file-upload svg {
|
||||||
width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2;
|
width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2;
|
||||||
stroke-linecap: round; stroke-linejoin: round;
|
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 {
|
.files-panel .file-row {
|
||||||
display: flex; align-items: center; gap: 10px;
|
display: flex; align-items: center; gap: 8px;
|
||||||
padding: 8px 10px; border-radius: 10px; font-size: 13.5px;
|
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: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 {
|
.files-panel .file-name {
|
||||||
flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
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 {
|
.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:active { opacity: .75; }
|
||||||
.files-panel .file-act.del { color: #c0392b; }
|
.files-panel .file-act.view { background: var(--surface); color: var(--ink); }
|
||||||
.files-panel .file-act.del:active { background: #fdecea; }
|
.files-panel .file-act.del { background: #fdecea; color: #c0392b; }
|
||||||
|
.files-panel .file-act.del:active { opacity: .75; }
|
||||||
.files-panel .empty-tip {
|
.files-panel .empty-tip {
|
||||||
padding: 20px 10px; text-align: center; font-size: 13px; color: var(--gray-light);
|
padding: 20px 10px; text-align: center; font-size: 13px; color: var(--gray-light);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,10 +71,10 @@
|
|||||||
深度思考
|
深度思考
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button class="plus-btn" id="attach-btn" title="任务文件" aria-label="任务文件">
|
|
||||||
<svg viewBox="0 0 24 24" class="ic sm"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg>
|
|
||||||
</button>
|
|
||||||
<div class="ia-side ia-right">
|
<div class="ia-side ia-right">
|
||||||
|
<button class="plus-btn" id="attach-btn" title="任务文件" aria-label="任务文件">
|
||||||
|
<svg viewBox="0 0 24 24" class="ic sm"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path></svg>
|
||||||
|
</button>
|
||||||
<button class="send-btn" id="send-btn" title="发送" aria-label="发送">
|
<button class="send-btn" id="send-btn" title="发送" aria-label="发送">
|
||||||
<svg viewBox="0 0 24 24" class="ic sm"><line x1="12" y1="19" x2="12" y2="5"></line><polyline points="5 12 12 5 19 12"></polyline></svg>
|
<svg viewBox="0 0 24 24" class="ic sm"><line x1="12" y1="19" x2="12" y2="5"></line><polyline points="5 12 12 5 19 12"></polyline></svg>
|
||||||
</button>
|
</button>
|
||||||
@@ -108,14 +108,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<!-- ================= 任务文件面板(浮层:点输入行中部的附件按钮展开;盖住输入区+遮罩) ================= -->
|
<!-- ================= 任务文件面板(浮层:点输入行右侧发送旁的附件按钮展开;盖住输入区+遮罩) ================= -->
|
||||||
<div id="files-mask" aria-hidden="true"></div>
|
<div id="files-mask" aria-hidden="true"></div>
|
||||||
<div class="files-panel" id="files-panel" aria-label="任务文件">
|
<div class="files-panel" id="files-panel" aria-label="任务文件">
|
||||||
<div class="files-panel-header">
|
<div class="files-panel-header">
|
||||||
<span>任务文件</span>
|
<span>任务文件</span>
|
||||||
<label class="file-upload" title="上传文件">
|
<label class="file-upload" title="上传文件">
|
||||||
<input type="file" id="file-input" multiple hidden>
|
<input type="file" id="file-input" multiple hidden>
|
||||||
<svg viewBox="0 0 24 24"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
|
<svg viewBox="0 0 24 24"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"></path><polyline points="17 8 12 3 7 8"></polyline><line x1="12" y1="3" x2="12" y2="15"></line></svg>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="files-list" id="files-list"></div>
|
<div class="files-list" id="files-list"></div>
|
||||||
@@ -1146,7 +1146,7 @@
|
|||||||
toast(state.deepThink ? '深度思考已开启(暂不影响后端)' : '深度思考已关闭');
|
toast(state.deepThink ? '深度思考已开启(暂不影响后端)' : '深度思考已关闭');
|
||||||
});
|
});
|
||||||
|
|
||||||
// ---------- 任务文件面板(底部浮层:点输入行中部的附件按钮展开,遮罩盖住输入区) ----------
|
// ---------- 任务文件面板(底部浮层:点输入行右侧发送旁的附件按钮展开,遮罩盖住输入区) ----------
|
||||||
function setFilesPanel(open) {
|
function setFilesPanel(open) {
|
||||||
const panel = $('files-panel');
|
const panel = $('files-panel');
|
||||||
if (open) {
|
if (open) {
|
||||||
@@ -1176,15 +1176,33 @@
|
|||||||
el.innerHTML = '<div class="empty-tip">还没有文件,在对话框上传或让 AI 生成</div>';
|
el.innerHTML = '<div class="empty-tip">还没有文件,在对话框上传或让 AI 生成</div>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
el.innerHTML = files.map(f =>
|
el.innerHTML = files.map(f => {
|
||||||
'<div class="file-row" data-path="' + esc(f.filename) + '">' +
|
const isMd = /\.md$/i.test(f.filename);
|
||||||
|
return '<div class="file-row' + (isMd ? ' clickable' : '') + '" data-path="' + esc(f.filename) + '">' +
|
||||||
|
'<svg class="file-ico" viewBox="0 0 24 24"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline></svg>' +
|
||||||
'<span class="file-name">' + esc(String(f.filename).split('/').pop() || f.filename) + '</span>' +
|
'<span class="file-name">' + esc(String(f.filename).split('/').pop() || f.filename) + '</span>' +
|
||||||
'<span class="file-size">' + fmtSize(f.size) + '</span>' +
|
'<span class="file-size">' + fmtSize(f.size) + '</span>' +
|
||||||
|
(isMd ? '<button class="file-act view" title="预览">预览</button>' : '') +
|
||||||
'<button class="file-act" title="下载">下载</button>' +
|
'<button class="file-act" title="下载">下载</button>' +
|
||||||
'<button class="file-act del" title="删除">删</button>' +
|
'<button class="file-act del" title="删除">删除</button>' +
|
||||||
'</div>').join('');
|
'</div>';
|
||||||
|
}).join('');
|
||||||
} catch (e) { toast('读取文件失败:' + e.message); }
|
} 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 = '<div class="bubble-ai' + (r2.fmt ? ' md' : '') + '">' + r2.html + '</div>';
|
||||||
|
openFullscreen(wrap.firstChild); // 复用双击气泡的全屏查看器
|
||||||
|
} catch (e) { toast('预览失败:' + e.message); }
|
||||||
|
}
|
||||||
async function downloadFile(name) {
|
async function downloadFile(name) {
|
||||||
if (!state.sessionId) return;
|
if (!state.sessionId) return;
|
||||||
try {
|
try {
|
||||||
@@ -1205,6 +1223,7 @@
|
|||||||
const path = row.dataset.path;
|
const path = row.dataset.path;
|
||||||
if (!path) return;
|
if (!path) return;
|
||||||
if (e.target.closest('.del')) deleteFile(path);
|
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);
|
else if (e.target.closest('.file-act')) downloadFile(path);
|
||||||
});
|
});
|
||||||
// 面板内上传:直接写入当前会话任务目录
|
// 面板内上传:直接写入当前会话任务目录
|
||||||
|
|||||||
Reference in New Issue
Block a user