会话标题可点击重命名

This commit is contained in:
2026-09-02 14:32:58 +08:00
parent 866978532d
commit 2843eb9496
4 changed files with 35 additions and 6 deletions
+6 -6
View File
@@ -143,7 +143,7 @@
<button class="icon-btn back-btn" onclick="ui.backToList()">
<svg viewBox="0 0 24 24"><polyline points="15 18 9 12 15 6"></polyline></svg>
</button>
<span class="chat-title" id="chat-title"></span>
<span class="chat-title" id="chat-title" onclick="ui.renameSession()" title="点击重命名" style="cursor:pointer"></span>
<div class="header-right">
<button class="icon-btn" onclick="ui.toggleFiles(event)" title="文件">
<svg viewBox="0 0 24 24"><path d="M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"></path></svg>
@@ -295,10 +295,10 @@
<div class="toast hidden" id="toast"></div>
<!-- 发版时更新 v 参数,避免移动端浏览器缓存旧 JS -->
<script src="/js/core.js?v=20260902c"></script>
<script src="/js/tasks.js?v=20260902c"></script>
<script src="/js/skills.js?v=20260902c"></script>
<script src="/js/models.js?v=20260902c"></script>
<script src="/js/settings.js?v=20260902c"></script>
<script src="/js/core.js?v=20260902d"></script>
<script src="/js/tasks.js?v=20260902d"></script>
<script src="/js/skills.js?v=20260902d"></script>
<script src="/js/models.js?v=20260902d"></script>
<script src="/js/settings.js?v=20260902d"></script>
</body>
</html>
+12
View File
@@ -538,6 +538,18 @@ const ui = {
$('new-title').focus();
},
closeCreate() { $('create-modal').classList.add('hidden'); },
async renameSession() {
if (!state.sessionId) return;
const cur = $('chat-title').textContent;
const t = await promptModal('重命名会话', '输入新的会话名称', cur === state.sessionId ? '' : cur);
if (t === null) return; // 取消
try {
await req('PATCH', '/api/sessions/' + state.sessionId, { title: t });
toast('已重命名');
$('chat-title').textContent = t.trim();
loadSessions();
} catch (e) { toast('重命名失败:' + e.message); }
},
async openModelSwitch() {
if (!state.sessionId) return;
const list = $('bind-model-list');