diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css
index 0d7d2b6..4b2508b 100644
--- a/app/server/public/css/style.css
+++ b/app/server/public/css/style.css
@@ -981,10 +981,12 @@ label.icon-btn { cursor: pointer; }
.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; }
+/* 模型子卡片:上行 id+删除,下行 vision/enable 勾选 */
+.modal .mpe-mcard { border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; margin-bottom: 8px; background: #fafbfd; }
+.modal .mpe-mcard .mpe-row { margin-bottom: 0; }
+.modal .mpe-cks { display: flex; align-items: center; gap: 16px; margin-top: 8px; }
+.modal .mpe-ck { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--gray); }
+.modal .mpe-ck 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; }
diff --git a/app/server/public/index.html b/app/server/public/index.html
index bd87733..76a6c3d 100644
--- a/app/server/public/index.html
+++ b/app/server/public/index.html
@@ -239,7 +239,6 @@
' +
- '
' +
- '
' +
- '
' +
- '
' +
+ return '
';
}
// 行下标变化后需重渲染(事件处理器里捕获了旧 i),故增删后重建两段行列表。
@@ -3367,8 +3369,8 @@
$('mpe-keys').innerHTML = pfEdit.keys.map(pfKeysRowHtml).join('') || '
至少保留一个 Key
';
$('mpe-models').innerHTML = pfEdit.models.map(pfModelsRowHtml).join('') || '
至少保留一个模型
';
}
- function addPfKey() { if (!pfEdit) return; pfEdit.keys.push({ ref: null, api_key: '', concurrency: 1 }); renderPfRows(); }
- function addPfModel() { if (!pfEdit) return; pfEdit.models.push({ ref: null, id: '', display_name: '', vision: false, enable: true }); renderPfRows(); }
+ function addPfKey() { if (!pfEdit) return; pfEdit.keys.push({ ref: null, api_key: '' }); renderPfRows(); }
+ function addPfModel() { if (!pfEdit) return; pfEdit.models.push({ ref: null, id: '', vision: false, enable: true }); renderPfRows(); }
function delPfKey(i) {
if (!pfEdit) return;
if (pfEdit.keys.length <= 1) return toast('至少保留一个 Key');
@@ -3389,46 +3391,30 @@
const edits = [];
const name = $('mpe-name').value.trim();
const url = $('mpe-url').value.trim().replace(/\/+$/, '');
- let type = $('mpe-type').value.trim();
- // type 置空 = 「跟随平台名」:原配置显式配过 type 且与 name 不同的,写回新 name(规范化后等价缺省)
- const effName = name || p.name;
- if (!type && p.type && p.type !== p.name) type = effName;
if (name && name !== p.name) edits.push({ path: ['platforms', pfEdit.idx, 'name'], value: name });
if (url && url !== p.url) edits.push({ path: ['platforms', pfEdit.idx, 'url'], value: url });
- if (type && type !== p.type) edits.push({ path: ['platforms', pfEdit.idx, 'type'], value: type });
- // Key:concurrency 可原地改;已有 api_key 不写回(脱敏值会污染真 Key),换 Key 走删行+新增行
+ // Key:弹窗只配 api_key(concurrency/type 不进弹窗);已有 api_key 不写回(脱敏值会污染真 Key),换 Key 走删行+新增行
pfEdit.keys.forEach(r => {
- if (r.ref != null) {
- const oc = (p.keys[r.ref] || {}).concurrency || 1;
- const nc = Math.max(1, parseInt(r.concurrency, 10) || 1);
- if (nc !== oc) edits.push({ path: ['platforms', pfEdit.idx, 'keys', r.ref, 'concurrency'], value: nc });
- } else {
- edits.push({ op: 'append', path: ['platforms', pfEdit.idx, 'keys'], value: {
- api_key: String(r.api_key || '').trim(), concurrency: Math.max(1, parseInt(r.concurrency, 10) || 1),
- } });
- }
+ if (r.ref == null) edits.push({ op: 'append', path: ['platforms', pfEdit.idx, 'keys'], value: { api_key: String(r.api_key || '').trim() } });
});
const delKeys = [];
for (let ki = 0; ki < (p.keys || []).length; ki++) {
if (!pfEdit.keys.some(r => r.ref === ki)) delKeys.push(ki);
}
delKeys.sort((a, b) => b - a).forEach(ki => edits.push({ op: 'delete', path: ['platforms', pfEdit.idx, 'keys', ki] }));
- // 模型:整体覆盖改(保留 enable)/新增 append/删行;id 不可改故无新增行冲突
+ // 模型:已有行只按细粒度 path 改 vision/enable(不整体覆盖,保住文件里的 display_name/extra_params 等);
+ // 新增行 append 最小对象(缺省项不写:display_name 后端同 id,enable 缺省启用)
pfEdit.models.forEach(r => {
if (r.ref != null) {
const om = (p.models || [])[r.ref] || {};
- const nd = String(r.display_name || '').trim() || r.id;
- const ne = r.enable !== false;
- if ((om.display_name || '') !== nd || !!om.vision !== !!r.vision || (om.enable !== false) !== ne) {
- edits.push({ path: ['platforms', pfEdit.idx, 'models', r.ref], value: {
- id: om.id || r.id, display_name: nd, vision: !!r.vision, enable: ne,
- } });
- }
+ if (!!om.vision !== !!r.vision) edits.push({ path: ['platforms', pfEdit.idx, 'models', r.ref, 'vision'], value: !!r.vision });
+ if ((om.enable !== false) !== (r.enable !== false)) edits.push({ path: ['platforms', pfEdit.idx, 'models', r.ref, 'enable'], value: r.enable !== false });
} else {
const id = String(r.id || '').trim();
- edits.push({ op: 'append', path: ['platforms', pfEdit.idx, 'models'], value: {
- id, display_name: String(r.display_name || '').trim() || id, vision: !!r.vision,
- } });
+ const nv = { id };
+ if (r.vision) nv.vision = true;
+ if (r.enable === false) nv.enable = false;
+ edits.push({ op: 'append', path: ['platforms', pfEdit.idx, 'models'], value: nv });
}
});
const delMods = (p.models || []).map((_, i) => i).filter(i => !pfEdit.models.some(r => r.ref === i)).sort((a, b) => b - a);
@@ -3438,10 +3424,8 @@
async function saveModelEditor() {
if (!pfEdit) return;
const add = pfEdit.idx < 0;
- // 采集当前输入框值到工作态(避免用户只改最后一个框未触发 oninput 的边界)
const name = $('mpe-name').value.trim();
const url = $('mpe-url').value.trim().replace(/\/+$/, '');
- const type = $('mpe-type').value.trim();
if (!url) return toast('请填写平台上游地址');
if (!pfEdit.models.length) return toast('至少保留一个模型');
if (!pfEdit.keys.length) return toast('至少保留一个 Key');
@@ -3455,11 +3439,17 @@
let edits;
try {
if (add) {
- // 新增平台:一次 append 整个对象(name/url/type 留空由服务端规范化: name 取主机段、type 取 name)
+ // 新增平台:一次 append 整个对象(name 留空由服务端取主机段;type/concurrency/display_name 均不落配置,走各自缺省)
edits = [{ op: 'append', path: ['platforms'], value: {
- name, url, type,
- keys: pfEdit.keys.map(r => ({ api_key: String(r.api_key || '').trim(), concurrency: Math.max(1, parseInt(r.concurrency, 10) || 1) })),
- models: pfEdit.models.map(r => ({ id: String(r.id).trim(), display_name: String(r.display_name || '').trim() || String(r.id).trim(), vision: !!r.vision })),
+ name, url,
+ keys: pfEdit.keys.map(r => ({ api_key: String(r.api_key || '').trim() })),
+ models: pfEdit.models.map(r => {
+ const id = String(r.id).trim();
+ const nv = { id };
+ if (r.vision) nv.vision = true;
+ if (r.enable === false) nv.enable = false;
+ return nv;
+ }),
} }];
} else {
// 改名不影响 pi(数组位置);其余按原 ref 定位,见 buildPfEdits
@@ -3531,10 +3521,9 @@
mAddModel: addPfModel,
mDelModel: delPfModel,
mKeyApi: function (i, v) { setPfKey(i, 'api_key', v); },
- mKeyCon: function (i, v) { setPfKey(i, 'concurrency', v); },
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); },
+ mModEnable: function (i, v) { setPfModel(i, 'enable', v); },
mDelPlat: delPlatformFromModal,
toggleGroup: toggleModelGroup,
refreshBalance: refreshBalance,