@wfm-cn/dsh-mcp-connectors 0.3.1 → 0.3.4
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/client.js +25 -12
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -67,8 +67,8 @@ window.__ModuleLoader__.load({
|
|
|
67
67
|
presetGithub: 'GitHub(官方 MCP · 需 Personal Access Token)',
|
|
68
68
|
presetCustom: '自定义 / 其他 MCP 服务',
|
|
69
69
|
composerOpen: '连接器',
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
selectAll: '全选',
|
|
71
|
+
deselectAll: '全部取消',
|
|
72
72
|
loadFailed: '加载失败',
|
|
73
73
|
retry: '重试',
|
|
74
74
|
hint: '工具将以 mcp__<标识>__<工具名> 出现在会话中。',
|
|
@@ -124,8 +124,8 @@ window.__ModuleLoader__.load({
|
|
|
124
124
|
presetGithub: 'GitHub (official MCP · needs a Personal Access Token)',
|
|
125
125
|
presetCustom: 'Custom MCP server',
|
|
126
126
|
composerOpen: 'Connectors',
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
selectAll: 'Select all',
|
|
128
|
+
deselectAll: 'Deselect all',
|
|
129
129
|
loadFailed: 'Failed to load',
|
|
130
130
|
retry: 'Retry',
|
|
131
131
|
hint: 'Tools appear as mcp__<server>__<tool> in conversations.',
|
|
@@ -631,12 +631,26 @@ window.__ModuleLoader__.load({
|
|
|
631
631
|
const next = new Set(chosen);
|
|
632
632
|
if (next.has(sn)) next.delete(sn); else next.add(sn);
|
|
633
633
|
const r = await api.setSession({ sessionId, enabled: [...next] });
|
|
634
|
-
if (r.ok)
|
|
634
|
+
if (r.ok) applySession(next);
|
|
635
635
|
};
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
636
|
+
/** 与后端 POST /session 的落盘规则保持镜像:全选时删除会话记录(=默认全启用),否则保存列表 */
|
|
637
|
+
const applySession = (nextSet) => {
|
|
638
|
+
setData((d) => {
|
|
639
|
+
const sessions = { ...(d?.sessions ?? {}) };
|
|
640
|
+
const allOn = enabledConnectors.length > 0
|
|
641
|
+
&& enabledConnectors.every((c) => nextSet.has(c.serverName));
|
|
642
|
+
if (allOn) delete sessions[sessionId];
|
|
643
|
+
else sessions[sessionId] = [...nextSet];
|
|
644
|
+
return { ...d, sessions };
|
|
645
|
+
});
|
|
646
|
+
};
|
|
647
|
+
const allOn = Boolean(chosen) && enabledConnectors.length > 0
|
|
648
|
+
&& enabledConnectors.every((c) => chosen.has(c.serverName));
|
|
649
|
+
const toggleAll = async () => {
|
|
650
|
+
if (!sessionId || !api || !chosen) return;
|
|
651
|
+
const next = allOn ? new Set() : new Set(enabledConnectors.map((c) => c.serverName));
|
|
652
|
+
const r = await api.setSession({ sessionId, enabled: [...next] });
|
|
653
|
+
if (r.ok) applySession(next);
|
|
640
654
|
};
|
|
641
655
|
|
|
642
656
|
return h('div', { className: 'mcx-composer', ref: wrapRef },
|
|
@@ -652,7 +666,7 @@ window.__ModuleLoader__.load({
|
|
|
652
666
|
: h(React.Fragment, null,
|
|
653
667
|
h('div', { className: 'mcx-popover-head' },
|
|
654
668
|
h('span', null, t('composerOpen')),
|
|
655
|
-
h('button', { type: 'button', className: 'mcx-chipbtn', onClick:
|
|
669
|
+
h('button', { type: 'button', className: 'mcx-chipbtn', onClick: toggleAll }, t(allOn ? 'deselectAll' : 'selectAll'))),
|
|
656
670
|
enabledConnectors.map((c) => h('label', { key: c.id, className: 'mcx-popover-row' },
|
|
657
671
|
h('input', {
|
|
658
672
|
type: 'checkbox',
|
|
@@ -660,8 +674,7 @@ window.__ModuleLoader__.load({
|
|
|
660
674
|
onChange: () => toggleServer(c.serverName),
|
|
661
675
|
}),
|
|
662
676
|
h('span', { className: 'mcx-popover-name' }, c.title || c.serverName),
|
|
663
|
-
h('span', { className: 'mcx-popover-sub' }, c.transport)))
|
|
664
|
-
chosen && chosen.size === 0 && h('div', { className: 'mcx-popover-empty' }, t('composerNone')))));
|
|
677
|
+
h('span', { className: 'mcx-popover-sub' }, c.transport))))));
|
|
665
678
|
}
|
|
666
679
|
|
|
667
680
|
/* ---------------- 样式(仅主题 token) ---------------- */
|