From 24ec5a6089707c5a7701fc73d97e4cce945ac578 Mon Sep 17 00:00:00 2001 From: cc-dan Date: Tue, 10 Mar 2026 10:20:18 +0000 Subject: [PATCH] fix: show empty-state add button when no model templates exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When switching to custom mode with no templates, show a '+ 新建模板' button instead of an empty dropdown, allowing users to create the first template without any UI dead-end. --- public/app.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/public/app.js b/public/app.js index f055d42..6785e16 100644 --- a/public/app.js +++ b/public/app.js @@ -1165,6 +1165,24 @@ `` ).join(''); + if (modelEditingTemplates.length === 0) { + modelCustomArea.innerHTML = ` +
尚无模板,点击下方按钮新建。
+
+ +
+ `; + panel.querySelector('#model-tpl-add-first').addEventListener('click', () => { + const newName = prompt('输入新模板名称:'); + if (!newName || !newName.trim()) return; + const n = newName.trim(); + modelEditingTemplates.push({ name: n, apiKey: '', apiBase: '', defaultModel: '', opusModel: '', sonnetModel: '', haikuModel: '' }); + modelActiveTemplate = n; + renderModelTemplateEditor(); + }); + return; + } + modelCustomArea.innerHTML = `