diff --git a/app/server/public/css/style.css b/app/server/public/css/style.css index 0c6297c..3b4566d 100644 --- a/app/server/public/css/style.css +++ b/app/server/public/css/style.css @@ -1370,7 +1370,7 @@ label.icon-btn { cursor: pointer; } .modal .mpe-unit { position: relative; flex: none; width: 118px; } .modal .mpe-unit input { width: 100%; margin: 0; padding: 8px 30px 8px 10px; } .modal .mpe-unit i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; font-size: 11.5px; color: var(--gray-light); pointer-events: none; } -/* 预设模式下 name/url 是契约值(只读),压暗以区别于可编辑输入框 */ +/* 预设模式下 name 是契约值(只读),压暗以区别于可编辑输入框 */ .modal input[readonly] { background: #f1f3f7; color: var(--gray); } .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; } diff --git a/app/server/public/index.html b/app/server/public/index.html index 0c14fa3..a45e8fb 100644 --- a/app/server/public/index.html +++ b/app/server/public/index.html @@ -369,7 +369,7 @@

编辑 MCP 服务

- + '; } // 弹窗打开:add 模式 (idx=null) → 空工作态;edit 模式 → 从当前配置复制。 - // presetKey 有值 = 内置服务模式:url/name/mode 是契约(只读),表单由预设的 fields 生成。 + // presetKey 有值 = 内置服务模式:name/mode 是契约(只读),url 可改(地址随部署形态变,预设只给缺省值), + // 表单由预设的 fields 生成。 function openMcpEditor(idx, presetKey) { const preset = presetKey ? (presetMcpList().find(p => p.key === presetKey) || null) : null; const add = idx == null; @@ -1753,9 +1758,11 @@ } $('mce-title').textContent = (add ? '添加 ' : '编辑 ') + (preset ? preset.label : 'MCP 服务'); $('mce-name').value = preset ? preset.key : (add ? '' : (s.name || '')); - $('mce-url').value = preset ? preset.url : (add ? '' : (s.url || '')); + // 预填优先级:当前配置 > 预设缺省值。url 不锁只读——容器形态是 mcp_*:3000,本地形态是 + // 127.0.0.1:809x,漏改这里用户就看不到也改不了真实地址。 + $('mce-url').value = add ? (preset ? preset.url : '') : (s.url || (preset ? preset.url : '')); $('mce-name').readOnly = !!preset; - $('mce-url').readOnly = !!preset; + $('mce-url').readOnly = false; // 运行配置里的 timeout_ms 已被 config.js 填上缺省值,所以这里显示的就是当前生效值(没配则为 60000)。 $('mce-timeout').value = add || s.timeout_ms == null ? '' : String(s.timeout_ms); // 预设的 mode 是契约(asr / image_task 必须 skill 才不会把一堆转写/生成工具塞进每轮工具表), @@ -1888,11 +1895,13 @@ if (!Number.isFinite(tmo) || tmo < 1000 || tmo > 600000) throw new Error('超时要填 1000 ~ 600000 毫秒(留空 = 默认 60s)'); tmo = Math.round(tmo); } - // 内置服务的 name/url 是契约(表单只读),只有自定义服务才从输入框取 - const name = preset ? preset.key : $('mce-name').value.trim(); - const url = preset ? preset.url : $('mce-url').value.trim(); - const headers = preset ? presetHeaders() : plainHeaders(); + // name 是契约(预设的服务名固定);url 不再是契约——展示与写盘均以 config 为准, + // 输入框里默认的就是预设值,改了就存。 const add = mcpEdit.idx < 0; + const cur = add ? {} : (SET.cfgMcp[mcpEdit.idx] || {}); + const name = preset ? preset.key : $('mce-name').value.trim(); + const url = $('mce-url').value.trim(); + const headers = preset ? presetHeaders() : plainHeaders(); if (add) { if (!url) throw new Error('请填写 url'); const obj = { url }; @@ -1902,12 +1911,10 @@ if (Object.keys(headers).length) obj.headers = headers; edits.push({ op: 'append', path: ['mcp_servers'], value: obj }); } else { - const cur = SET.cfgMcp[mcpEdit.idx] || {}; - if (!preset) { - if (!url) throw new Error('请填写 url'); - if (name !== (cur.name || '')) edits.push({ path: ['mcp_servers', mcpEdit.idx, 'name'], value: name }); - if (url !== (cur.url || '')) edits.push({ path: ['mcp_servers', mcpEdit.idx, 'url'], value: url }); - } + // 自定义服务:name/url 都能改;内置服务只允许改 url(name/mode 是契约) + if (!url) throw new Error('请填写 url'); + if (!preset && name !== (cur.name || '')) edits.push({ path: ['mcp_servers', mcpEdit.idx, 'name'], value: name }); + if (url !== (cur.url || '')) edits.push({ path: ['mcp_servers', mcpEdit.idx, 'url'], value: url }); // mode:默认值不写进文件(选 advertise 就删键) if ((cur.mode || 'advertise') !== mode) edits.push(mode === 'advertise' ? { path: ['mcp_servers', mcpEdit.idx, 'mode'], op: 'delete' }