diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index 865c344..0d7d2b6 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -972,19 +972,21 @@ label.icon-btn { cursor: pointer; } .model-en-sw input:checked + .sw-track { background: var(--active); } .model-en-sw input:checked + .sw-track::after { transform: translateX(14px); } -/* ---------- 平台编辑/新增弹窗(模型池共用) ---------- */ +/* ---------- 平台编辑/新增弹窗(模型池共用) ---------- + 注:选择器均带 .modal 前缀提权——.modal input{width:100%}(0,1,1) 会盖过 + 单类(0,1,0)与同权但位置靠前的规则,导致行内输入框撑出卡片。 */ .modal.modal-wide { max-width: 480px; } -.mpe-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 8px; font-size: 13px; font-weight: 600; color: var(--ink); } -.mpe-sec-head .ghost-btn.sm { flex: none; padding: 4px 12px; font-size: 12.5px; border-radius: 8px; } -.mpe-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; } -.mpe-row input { margin-bottom: 0; padding: 8px 10px; font-size: 13px; } -.mpe-grow { flex: 1; min-width: 0; } -.mpe-con { width: 56px; flex: none; } -.mpe-mid { width: 104px; flex: none; } -.mpe-vis { flex: none; display: flex; align-items: center; gap: 3px; font-size: 12px; color: var(--gray); margin: 0; width: auto; } -.mpe-vis input { width: 15px; height: 15px; padding: 0; margin: 0; accent-color: var(--active); cursor: pointer; } -.mpe-del { flex: none; border: none; background: none; margin: 0; padding: 2px 7px; cursor: pointer; color: var(--gray-light); font-size: 18px; line-height: 1.2; } -.mpe-del:active { color: #c0392b; } +.modal .mpe-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 14px 0 8px; font-size: 13px; font-weight: 600; color: var(--ink); } +.modal .mpe-sec-head .ghost-btn.sm { flex: none; padding: 4px 12px; font-size: 12.5px; border-radius: 8px; } +.modal .mpe-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; } +.modal .mpe-row input { width: auto; margin-bottom: 0; padding: 8px 10px; font-size: 13px; } +.modal .mpe-grow { flex: 1; min-width: 0; } +.modal .mpe-con { flex: none; width: 56px; } +.modal .mpe-mid { flex: none; width: 104px; } +.modal .mpe-vis { flex: none; display: flex; align-items: center; gap: 3px; font-size: 12px; color: var(--gray); margin: 0; width: auto; } +.modal .mpe-vis input { width: 15px; height: 15px; padding: 0; margin: 0; border: none; background: none; accent-color: var(--active); cursor: pointer; } +.modal .mpe-del { flex: none; border: none; background: none; margin: 0; padding: 2px 7px; cursor: pointer; color: var(--gray-light); font-size: 18px; line-height: 1.2; } +.modal .mpe-del:active { color: #c0392b; } /* ---------- 编辑器页(config.yml 原文 / 技能文件) ---------- */ .set-editor { diff --git a/app/server/public/index.html b/app/server/public/index.html index b8d7f84..bd87733 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -244,10 +244,12 @@
模型
+
+
-
写入 config.yml,到「服务」页重启后生效。已有 Key 仅显示脱敏值,换 Key 请删行后重加;模型 id 不可改(历史会话按 id 绑定)。改平台名等于重建其下所有模型。
+
仅写入 config.yml,不影响其他数据。已有 Key 只显示脱敏值,换 Key 请删行后重加。
@@ -2826,9 +2828,12 @@ } renderSetPage(); } - // 重启服务(搬自 settings.js restart) + // 重启服务(搬自 settings.js restart):确认弹窗 + 执行。可复用部分拆为 restartNow(平台弹窗勾选「保存后立即重启」直用)。 async function restart() { if (!await confirmModal('重启服务', '重启服务使新配置生效?正在执行的 AI 会话会被打断。', '重启')) return; + await restartNow(); + } + async function restartNow() { try { await req('POST', '/api/system/restart'); } catch (e) { @@ -3309,7 +3314,7 @@ loadModelCards(); } // ---------- 平台编辑/新增弹窗(共用一套 UI 与渲染) ---------- - // SET.pfEdit 工作态:keys/models 行数组;ref=null 为弹窗新增行,ref=原配置下标(仅保存时算 diff 用)。 + // pfEdit 工作态:keys/models 行数组;ref=null 为弹窗新增行,ref=原配置下标(仅保存时算 diff 用)。 // 保存 = 一次批量 PATCH(body.edits),服务端同一次读文/校验/写盘,原子生效。 let pfEdit = null; // 当前平台名下的去重模型列表(打平 cfgModels 取首份 key 副本,已含 deletedModels/pendingEnable 过滤) @@ -3332,6 +3337,8 @@ // 运行态 type = 规范化后的值(缺省已填 name);与 name 相同时置空,表示“跟随平台名” $('mpe-type').value = add ? '' : ((p.type && p.type !== p.name) ? p.type : ''); if (add) { pfEdit.keys.push({ ref: null, api_key: '', concurrency: 1 }); pfEdit.models.push({ ref: null, id: '', display_name: '', vision: false, enable: true }); } + $('mpe-restart').checked = true; // 默认勾选「保存后立即重启」 + $('mpe-del-btn').classList.toggle('hidden', add); renderPfRows(); $('model-edit-modal').classList.remove('hidden'); } @@ -3348,7 +3355,7 @@ const isNew = r.ref == null; return '
' + '' + + (isNew ? ' oninput="sUI.mModId(' + i + ',this.value)"' : ' disabled title="不可修改"') + '>' + '' + '' + '' + @@ -3465,8 +3472,25 @@ if (!add) for (const r of pfEdit.models) if (r.ref == null) delete SET.deletedModels[pname + '/' + String(r.id || '').trim()]; closeModelEditor(); afterWrite(); + // 勾选「保存后立即重启」:配置已落盘,直接走重启流程(含 409 强打确认 + 健库轮询自刷新) + if ($('mpe-restart') && $('mpe-restart').checked) await restartNow(); } catch (e) { toast('保存失败:' + e.message); } } + // 删除整个平台:仅改 config.yml(一次 delete platforms[pi]),重启前列表已无它(effective 实时解析文件) + async function delPlatformFromModal() { + if (!pfEdit || pfEdit.idx < 0) return; + const pi = pfEdit.idx; + const p = SET.cfgPlatforms[pi] || {}; + closeModelEditor(); + const ok = await confirmModal('删除平台', '删除平台「' + (p.name || ('平台' + pi)) + '」及其全部 Key 与模型?此操作仅修改 config.yml。', '删除', true); + if (!ok) return; + try { + await req('PATCH', '/api/config', { path: ['platforms', pi], op: 'delete' }); + // 运行池重启前仍持有该平台的模型:标记隐藏,防会话页选择弹窗误绑 + for (const m of (p.models || [])) SET.deletedModels[p.name + '/' + m.id] = true; + afterWrite(); + } catch (e) { toast('删除失败:' + e.message); } + } // ---------- 设置区对外接口(动态卡片里的 onclick 均指向这里) ---------- window.sUI = { @@ -3511,6 +3535,7 @@ mModId: function (i, v) { setPfModel(i, 'id', v); }, mModName: function (i, v) { setPfModel(i, 'display_name', v); }, mModVision: function (i, v) { setPfModel(i, 'vision', v); }, + mDelPlat: delPlatformFromModal, toggleGroup: toggleModelGroup, refreshBalance: refreshBalance, mToggleEnable: toggleModelEnable,