@srgay/cursor-extension 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -391,6 +391,18 @@
|
|
|
391
391
|
refreshOptionLabels();
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
+
// 确保隐藏 select(数据载体)里存在某端口的 option。自定义浮层用 foundPorts 渲染,
|
|
395
|
+
// 但隐藏 select 只在全量扫描时重填;按需扫描新发现的端口必须补进来,否则给原生
|
|
396
|
+
// <select> 设一个不存在的 value 会被静默置空 → 连空端口 offline。
|
|
397
|
+
function ensurePortOption(value) {
|
|
398
|
+
if (!els.portSelect) return;
|
|
399
|
+
const v = String(value);
|
|
400
|
+
const opts = Array.from(els.portSelect.options);
|
|
401
|
+
if (opts.some((o) => o.value === v)) return;
|
|
402
|
+
const custom = opts.find((o) => o.value === config.customValue);
|
|
403
|
+
els.portSelect.insertBefore(h("option", { value: v }), custom || null);
|
|
404
|
+
}
|
|
405
|
+
|
|
394
406
|
function makeScanIcon() {
|
|
395
407
|
const svg = svgEl("svg", { viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true" });
|
|
396
408
|
svg.appendChild(svgEl("circle", { cx: "11", cy: "11", r: "6", stroke: "currentColor", "stroke-width": "2" }));
|
|
@@ -828,7 +840,11 @@
|
|
|
828
840
|
|
|
829
841
|
// 点选某端口:写回隐藏 select 的 value,关菜单,刷新按钮,再走既有连接逻辑(onPortChange)。
|
|
830
842
|
function selectPort(port) {
|
|
831
|
-
|
|
843
|
+
const v = String(port);
|
|
844
|
+
// 关键:浮层从 foundPorts 渲染,可能领先于隐藏 select 的 options;先补齐再赋值,
|
|
845
|
+
// 否则原生 <select> 对不存在的 value 会静默置空,导致连空端口 → offline。
|
|
846
|
+
ensurePortOption(v);
|
|
847
|
+
els.portSelect.value = v;
|
|
832
848
|
closePortMenu();
|
|
833
849
|
updatePortButton();
|
|
834
850
|
onPortChange();
|
|
@@ -1575,8 +1591,9 @@
|
|
|
1575
1591
|
: "扫描完成:" + from + "–" + to + " 未发现活跃 MCP 端口。";
|
|
1576
1592
|
|
|
1577
1593
|
if (refreshOnly) {
|
|
1578
|
-
//
|
|
1579
|
-
//
|
|
1594
|
+
// 自定义下拉:先把本次扫到的端口补进隐藏 select(数据载体),保证点选时 value 设得上;
|
|
1595
|
+
// 菜单仍展开则用最新结果渲染浮层(渲染后保持稳定,点选即时生效、无打断、无闪)。
|
|
1596
|
+
found.forEach((p) => ensurePortOption(String(p)));
|
|
1580
1597
|
if (state.expanded) renderPortMenu();
|
|
1581
1598
|
return;
|
|
1582
1599
|
}
|