2.0阶段5调整3: 任务标题去图标;技能改名/删除移至列表卡右侧;详情页顶栏仅留上传,新建文件改为列表下按钮,文件列表白卡+图标+胶囊美化

This commit is contained in:
2026-09-01 22:25:17 +08:00
parent 21e5a5d2cc
commit d645c00dd8
3 changed files with 67 additions and 55 deletions
+26 -8
View File
@@ -31,14 +31,6 @@ body {
} }
.header-left { display: flex; align-items: center; gap: 8px; flex: 1; } .header-left { display: flex; align-items: center; gap: 8px; flex: 1; }
.header h2 { font-size: 17px; font-weight: 600; white-space: nowrap; } .header h2 { font-size: 17px; font-weight: 600; white-space: nowrap; }
.brand {
display: inline-flex;
align-items: center;
gap: 8px;
cursor: default;
padding: 4px 8px;
border-radius: 6px;
}
.chat-title { .chat-title {
flex: 1; text-align: center; font-size: 16px; font-weight: 600; flex: 1; text-align: center; font-size: 16px; font-weight: 600;
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
@@ -346,6 +338,32 @@ body {
font-size: 12px; color: #888; margin-top: 3px; font-size: 12px; color: #888; margin-top: 3px;
display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
} }
/* 列表卡右侧操作钮 */
.card-acts { display: flex; flex-direction: column; gap: 10px; align-items: flex-end; flex-shrink: 0; }
.card-act {
background: #eef3fc; color: #2a5299; border: none; border-radius: 8px;
font-size: 12px; padding: 5px 10px; cursor: pointer;
}
.card-act.del { background: #fdecea; color: #c0392b; }
.card-act:active { opacity: 0.7; }
/* 技能详情文件列表:白卡包裹 + 行图标/胶囊 */
.skill-files {
background: #fff; border-radius: 12px; padding: 6px 8px;
box-shadow: 0 1px 4px rgba(30,40,90,0.06);
}
.skill-files .file-row { cursor: pointer; border-bottom: 1px dashed #eef0f5; }
.skill-files .file-row:last-child { border-bottom: none; }
.skill-files .file-ico {
width: 16px; height: 16px; flex-shrink: 0;
stroke: #7f8db0; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.skill-files .file-name { color: #223; font-weight: 500; }
.skill-files .file-size {
background: #f2f3f7; color: #8a93a6; font-size: 11px;
padding: 2px 8px; border-radius: 9px; flex-shrink: 0;
}
.skill-files .file-act { background: #eef3fc; border-radius: 7px; padding: 4px 9px; flex-shrink: 0; }
.skill-files .file-act.del { background: #fdecea; color: #c0392b; }
/* 代码/配置编辑器:全屏覆盖所在 Tab(盖住列表/详情与顶栏,不遮底部导航) */ /* 代码/配置编辑器:全屏覆盖所在 Tab(盖住列表/详情与顶栏,不遮底部导航) */
#skill-editor, #cfg-editor { #skill-editor, #cfg-editor {
position: absolute; inset: 0; z-index: 6; background: #f2f3f7; position: absolute; inset: 0; z-index: 6; background: #f2f3f7;
+6 -20
View File
@@ -16,12 +16,7 @@
<!-- ================= Tab:任务(会话列表) ================= --> <!-- ================= Tab:任务(会话列表) ================= -->
<div id="tab-tasks" class="tab-page hidden"> <div id="tab-tasks" class="tab-page hidden">
<div class="header"> <div class="header">
<div class="header-left"><div class="brand"> <div class="header-left"><h2>Agent 任务台</h2></div>
<svg width="24" height="24" viewBox="0 0 24 24" stroke="#fff" fill="none" stroke-width="1.5">
<rect x="3" y="3" width="18" height="18" rx="3"/><line x1="9" y1="9" x2="15" y2="9"/><line x1="9" y1="13" x2="15" y2="13"/><line x1="9" y1="17" x2="12" y2="17"/>
</svg>
<h2>Agent 任务台</h2>
</div></div>
<div style="display:flex; gap:2px; align-items:center;"> <div style="display:flex; gap:2px; align-items:center;">
<button class="icon-btn" id="create-session-btn" onclick="ui.openCreate()" title="新建任务"> <button class="icon-btn" id="create-session-btn" onclick="ui.openCreate()" title="新建任务">
<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"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
@@ -39,19 +34,10 @@
</button> </button>
<div class="header-left"><h2 id="skills-title">技能管理</h2></div> <div class="header-left"><h2 id="skills-title">技能管理</h2></div>
<div class="header-right"> <div class="header-right">
<button class="icon-btn hidden" id="skill-newfile-btn" onclick="skillsUI.newFile()" title="新建文件">
<svg 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><line x1="12" y1="12" x2="12" y2="18"></line><line x1="9" y1="15" x2="15" y2="15"></line></svg>
</button>
<label class="icon-btn hidden" id="skill-upload-btn" title="上传文件"> <label class="icon-btn hidden" id="skill-upload-btn" title="上传文件">
<input type="file" id="skill-file-input" style="display:none;" onchange="skillsUI.onUpload(event)"> <input type="file" id="skill-file-input" style="display:none;" onchange="skillsUI.onUpload(event)">
<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> <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>
<button class="icon-btn hidden" id="skill-rename-btn" onclick="skillsUI.renameSkill()" title="重命名">
<svg viewBox="0 0 24 24"><path d="M17 3a2.83 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5z"></path></svg>
</button>
<button class="icon-btn hidden" id="skill-del-btn" onclick="skillsUI.deleteSkill()" title="删除技能">
<svg viewBox="0 0 24 24"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path></svg>
</button>
<button class="icon-btn" id="skill-new-btn" onclick="skillsUI.openCreate()" title="新建技能"> <button class="icon-btn" id="skill-new-btn" onclick="skillsUI.openCreate()" title="新建技能">
<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"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg>
</button> </button>
@@ -261,10 +247,10 @@
<div class="toast hidden" id="toast"></div> <div class="toast hidden" id="toast"></div>
<!-- 发版时更新 v 参数,避免移动端浏览器缓存旧 JS --> <!-- 发版时更新 v 参数,避免移动端浏览器缓存旧 JS -->
<script src="/js/core.js?v=20260901h"></script> <script src="/js/core.js?v=20260901i"></script>
<script src="/js/tasks.js?v=20260901h"></script> <script src="/js/tasks.js?v=20260901i"></script>
<script src="/js/skills.js?v=20260901h"></script> <script src="/js/skills.js?v=20260901i"></script>
<script src="/js/models.js?v=20260901h"></script> <script src="/js/models.js?v=20260901i"></script>
<script src="/js/settings.js?v=20260901h"></script> <script src="/js/settings.js?v=20260901i"></script>
</body> </body>
</html> </html>
+35 -27
View File
@@ -14,11 +14,7 @@ let editorOrig = ''; // 打开/上次保存时的内容,用于脏检测
function setSkillsView(v) { function setSkillsView(v) {
$('skills-back-btn').classList.toggle('hidden', v === 'list'); $('skills-back-btn').classList.toggle('hidden', v === 'list');
$('skill-new-btn').classList.toggle('hidden', v !== 'list'); $('skill-new-btn').classList.toggle('hidden', v !== 'list');
const detailOnly = v === 'detail'; $('skill-upload-btn').classList.toggle('hidden', v !== 'detail');
$('skill-newfile-btn').classList.toggle('hidden', !detailOnly);
$('skill-upload-btn').classList.toggle('hidden', !detailOnly);
$('skill-rename-btn').classList.toggle('hidden', !detailOnly);
$('skill-del-btn').classList.toggle('hidden', !detailOnly);
$('skills-list').classList.toggle('hidden', v !== 'list'); $('skills-list').classList.toggle('hidden', v !== 'list');
$('skill-detail').classList.toggle('hidden', v !== 'detail'); $('skill-detail').classList.toggle('hidden', v !== 'detail');
$('skill-editor').classList.toggle('hidden', v !== 'editor'); $('skill-editor').classList.toggle('hidden', v !== 'editor');
@@ -37,8 +33,9 @@ async function loadSkillList() {
el.innerHTML = '<div class="empty-tip">还没有技能,点右上角 + 新建一个。</div>'; el.innerHTML = '<div class="empty-tip">还没有技能,点右上角 + 新建一个。</div>';
return; return;
} }
el.innerHTML = rows.map(s => el.innerHTML = rows.map(s => {
'<div class="session-card" onclick="skillsUI.open(\'' + encodeURIComponent(s.name) + '\')">' + const a = encodeURIComponent(s.name);
return '<div class="session-card" onclick="skillsUI.open(\'' + a + '\')">' +
'<div class="session-main">' + '<div class="session-main">' +
'<div class="session-name">' + esc(s.name) + '<div class="session-name">' + esc(s.name) +
(s.has_md ? '' : ' <span class="badge cancelled">缺 SKILL.md</span>') + (s.has_md ? '' : ' <span class="badge cancelled">缺 SKILL.md</span>') +
@@ -49,7 +46,12 @@ async function loadSkillList() {
'<span>' + fmtSize(s.size) + '</span>' + '<span>' + fmtSize(s.size) + '</span>' +
(s.mtime ? '<span>' + fmtTime(s.mtime) + '</span>' : '') + '</div>' + (s.mtime ? '<span>' + fmtTime(s.mtime) + '</span>' : '') + '</div>' +
'</div>' + '</div>' +
'</div>').join(''); '<div class="card-acts">' +
'<button class="card-act" onclick="event.stopPropagation();skillsUI.renameSkill(\'' + a + '\')">改名</button>' +
'<button class="card-act del" onclick="event.stopPropagation();skillsUI.deleteSkill(\'' + a + '\')">删除</button>' +
'</div>' +
'</div>';
}).join('');
} catch (e) { } catch (e) {
el.innerHTML = '<div class="empty-tip">加载失败:' + esc(e.message) + '</div>'; el.innerHTML = '<div class="empty-tip">加载失败:' + esc(e.message) + '</div>';
} }
@@ -63,19 +65,21 @@ async function loadSkillDetail() {
try { try {
const d = await req('GET', '/api/skills/' + encodeURIComponent(curSkill)); const d = await req('GET', '/api/skills/' + encodeURIComponent(curSkill));
$('skills-title').textContent = d.name; $('skills-title').textContent = d.name;
const newBtn = '<button class="ghost-btn" style="width:100%;margin-top:10px" onclick="skillsUI.newFile()">+ 新建文件</button>';
if (!d.files.length) { if (!d.files.length) {
el.innerHTML = '<div class="empty-tip">技能目录是空的。</div>'; el.innerHTML = '<div class="skill-files"><div class="empty-tip">技能目录是空的</div></div>' + newBtn;
return; return;
} }
el.innerHTML = d.files.map(f => { el.innerHTML = '<div class="skill-files">' + d.files.map(f => {
const a = encodeURIComponent(f.filename); const a = encodeURIComponent(f.filename);
return '<div class="file-row">' + return '<div class="file-row" onclick="skillsUI.editFile(\'' + a + '\')">' +
'<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(f.filename) + '</span>' + '<span class="file-name">' + esc(f.filename) + '</span>' +
'<span class="file-size">' + fmtSize(f.size) + '</span>' + '<span class="file-size">' + fmtSize(f.size) + '</span>' +
'<button class="file-act" onclick="skillsUI.editFile(\'' + a + '\')">编辑</button>' + '<button class="file-act" onclick="event.stopPropagation();skillsUI.editFile(\'' + a + '\')">编辑</button>' +
'<button class="file-act del" onclick="skillsUI.deleteFile(\'' + a + '\')">删</button>' + '<button class="file-act del" onclick="event.stopPropagation();skillsUI.deleteFile(\'' + a + '\')">删</button>' +
'</div>'; '</div>';
}).join(''); }).join('') + '</div>' + newBtn;
} catch (e) { } catch (e) {
el.innerHTML = '<div class="empty-tip">加载失败:' + esc(e.message) + '</div>'; el.innerHTML = '<div class="empty-tip">加载失败:' + esc(e.message) + '</div>';
} }
@@ -113,25 +117,29 @@ async function createSkill() {
} catch (e) { toast('创建失败:' + e.message); } } catch (e) { toast('创建失败:' + e.message); }
} }
async function renameSkill() { async function renameSkill(nameEnc) {
if (!curSkill) return; const name = nameEnc ? decodeURIComponent(nameEnc) : curSkill;
const nn = prompt('新的技能名:', curSkill); if (!name) return;
const nn = prompt('新的技能名:', name);
if (nn == null) return; if (nn == null) return;
const name = nn.trim(); const newName = nn.trim();
if (!name || name === curSkill) return; if (!newName || newName === name) return;
try { try {
await req('POST', '/api/skills/' + encodeURIComponent(curSkill) + '/rename', { newName: name }); await req('POST', '/api/skills/' + encodeURIComponent(name) + '/rename', { newName });
toast('已重命名为 ' + name); toast('已重命名为 ' + newName);
await openSkill(encodeURIComponent(name)); if (curSkill === name) { curSkill = newName; await loadSkillDetail(); }
else await loadSkillList();
} catch (e) { toast('重命名失败:' + e.message); } } catch (e) { toast('重命名失败:' + e.message); }
} }
async function deleteSkill() { async function deleteSkill(nameEnc) {
if (!curSkill) return; const name = nameEnc ? decodeURIComponent(nameEnc) : curSkill;
if (!confirm('确定删除技能「' + curSkill + '」?目录下所有文件将不可恢复。')) return; if (!name) return;
if (!confirm('确定删除技能「' + name + '」?目录下所有文件将不可恢复。')) return;
try { try {
await req('DELETE', '/api/skills/' + encodeURIComponent(curSkill)); await req('DELETE', '/api/skills/' + encodeURIComponent(name));
toast('已删除 ' + curSkill); toast('已删除 ' + name);
if (curSkill === name) curSkill = null;
loadSkillList(); loadSkillList();
} catch (e) { toast('删除失败:' + e.message); } } catch (e) { toast('删除失败:' + e.message); }
} }