UI:上传文件卡片改进——内嵌输入框、发送后自动清空、新卡倒序置顶、去掉单卡关闭钮
- 卡片行从 footer 顶部移入 .input-shell 内部顶端,随卡片撑高输入框;卡宽 210→158px,圆角/间距/字号收小 - send() 成功后 clearUploadCards():消息发出即认为文件提示使命完成,卡片整体清掉 - 新卡 prepend 到最前(最后上传显示在开头),入位后横向滚回左端 - 移除右上角 × 及其 CSS/监听:卡片不再单删,失败卡保留红字,统一由发送/切会话清空
This commit is contained in:
@@ -286,40 +286,33 @@ footer { flex: none; padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0
|
||||
}
|
||||
.attach-chip .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }
|
||||
.attach-chip .rm { color: var(--gray); display: flex; }
|
||||
/* 上传文件卡片行(输入区上方):逐卡进度遮罩;卡多时横向滚动 */
|
||||
/* 上传文件卡片行(嵌在输入框内部顶端,由 .input-shell 的 gap 提供间距;逐卡进度遮罩;卡多时横向滚动) */
|
||||
.up-cards {
|
||||
display: flex; gap: 8px; margin-bottom: 8px;
|
||||
display: flex; gap: 6px;
|
||||
overflow-x: auto; overflow-y: hidden;
|
||||
scrollbar-width: thin; padding-bottom: 2px;
|
||||
scrollbar-width: thin;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
.up-cards::-webkit-scrollbar { height: 4px; }
|
||||
.up-cards::-webkit-scrollbar-thumb { background: #ccd0da; border-radius: 2px; }
|
||||
.up-card {
|
||||
position: relative; flex: 0 0 auto;
|
||||
display: flex; align-items: center; gap: 8px;
|
||||
width: 210px; max-width: 62vw;
|
||||
background: var(--surface); border: 1px solid #e3e6ee; border-radius: 12px;
|
||||
padding: 9px 10px; overflow: hidden;
|
||||
display: flex; align-items: center; gap: 7px;
|
||||
width: 158px; max-width: 56vw;
|
||||
background: var(--surface); border: 1px solid #e3e6ee; border-radius: 10px;
|
||||
padding: 6px 8px; overflow: hidden;
|
||||
}
|
||||
.up-ico { color: var(--gray); display: flex; flex: none; }
|
||||
.up-ico .ic { width: 18px; height: 18px; }
|
||||
.up-info { flex: 1; min-width: 0; }
|
||||
.up-name { font-size: 12px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
.up-meta { font-size: 11px; color: var(--gray); margin-top: 2px; }
|
||||
.up-x {
|
||||
position: absolute; right: 5px; top: 5px; z-index: 2;
|
||||
width: 18px; height: 18px; border-radius: 50%; border: none; cursor: pointer; padding: 0;
|
||||
background: rgba(0, 0, 0, .06); color: var(--gray);
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.up-x:hover { background: rgba(0, 0, 0, .12); color: var(--ink); }
|
||||
.up-x .ic { width: 11px; height: 11px; stroke-width: 2.4; }
|
||||
.up-meta { font-size: 10.5px; color: var(--gray); margin-top: 1px; }
|
||||
.up-mask {
|
||||
position: absolute; inset: 0; z-index: 1;
|
||||
background: rgba(255, 255, 255, .78);
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.up-pct { font-size: 12px; font-weight: 600; color: var(--active); }
|
||||
.up-pct { font-size: 11px; font-weight: 600; color: var(--active); }
|
||||
.up-card.err .up-pct { color: #c0392b; }
|
||||
/* 底部进度线:宽度由 --up-p 驱动;终态(完成/失败)收起 */
|
||||
.up-card::after {
|
||||
|
||||
@@ -121,9 +121,9 @@
|
||||
|
||||
<!-- ================= 底部输入区 ================= -->
|
||||
<footer>
|
||||
<div class="up-cards hidden" id="up-cards" aria-label="已上传文件"></div>
|
||||
<div class="attach-chips hidden" id="attach-chips"></div>
|
||||
<div class="input-shell">
|
||||
<div class="up-cards hidden" id="up-cards" aria-label="已上传文件"></div>
|
||||
<textarea id="msg-input" placeholder="传送信息" rows="2" enterkeyhint="enter"></textarea>
|
||||
<div class="input-actions">
|
||||
<div class="ia-side ia-left">
|
||||
@@ -1434,6 +1434,7 @@
|
||||
if (pending.length) atts = await uploadFiles(id, pending);
|
||||
const body = { content, deepThink: !!state.deepThink };
|
||||
const sent = await req('POST', '/api/sessions/' + id + '/messages', body);
|
||||
clearUploadCards(); // 消息已发出,上传文件卡片完成提示使命,自动清掉
|
||||
|
||||
appendUserMsg(content, atts.map(a => a.name), sent && sent.message_id);
|
||||
if (!state.sessionTitle && content) {
|
||||
@@ -2447,7 +2448,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- 上传文件卡片(输入区上方:图标 + 文件名/类型大小,逐卡上传进度遮罩;过多横向滚动) ----------
|
||||
// ---------- 上传文件卡片(嵌在输入框内部顶端,随卡片数撑高输入框;新卡插最前,图标 + 文件名/类型大小,逐卡上传进度遮罩;过多横向滚动) ----------
|
||||
function uploadTypeLabel(name) {
|
||||
const m = /\.([A-Za-z0-9]{1,8})$/.exec(name || '');
|
||||
return m ? m[1].toUpperCase() : '文件';
|
||||
@@ -2468,19 +2469,14 @@
|
||||
'<div class="up-info">' +
|
||||
'<div class="up-name" title="' + esc(file.name) + '">' + esc(file.name) + '</div>' +
|
||||
'<div class="up-meta">' + uploadTypeLabel(file.name) + ' · ' + fmtSize(file.size) + '</div>' +
|
||||
'</div>' +
|
||||
'<button class="up-x hidden" title="关闭" aria-label="关闭"><svg class="ic" viewBox="0 0 24 24"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>' +
|
||||
'<div class="up-mask"><span class="up-pct">0%</span></div>';
|
||||
const mask = card.querySelector('.up-mask');
|
||||
const pctEl = card.querySelector('.up-pct');
|
||||
const closeBtn = card.querySelector('.up-x');
|
||||
closeBtn.addEventListener('click', () => {
|
||||
card.remove();
|
||||
if (!row.children.length) row.classList.add('hidden');
|
||||
});
|
||||
row.appendChild(card);
|
||||
// 卡片多到横向溢出时,新卡滚动到可见处
|
||||
card.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
||||
'</div>' +
|
||||
'<div class="up-mask"><span class="up-pct">0%</span></div>';
|
||||
const mask = card.querySelector('.up-mask');
|
||||
const pctEl = card.querySelector('.up-pct');
|
||||
// 无单卡删除入口:发送消息或切换会话时整体清空(clearUploadCards)
|
||||
// 倒序:最后上传的排最前;新卡入位后横向滚回左端保证可见
|
||||
row.prepend(card);
|
||||
row.scrollTo({ left: 0, behavior: 'smooth' });
|
||||
return {
|
||||
setPct(p) {
|
||||
const v = Math.max(0, Math.min(100, Math.round(p)));
|
||||
@@ -2490,12 +2486,10 @@
|
||||
done() {
|
||||
mask.remove();
|
||||
card.classList.add('done');
|
||||
closeBtn.classList.remove('hidden');
|
||||
},
|
||||
fail() {
|
||||
card.classList.add('err');
|
||||
mask.innerHTML = '<span class="up-pct">上传失败</span>';
|
||||
closeBtn.classList.remove('hidden');
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user