@wfm-cn/dsh-mcp-connectors 0.3.0 → 0.3.2
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 -19
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -68,7 +68,8 @@ window.__ModuleLoader__.load({
|
|
|
68
68
|
presetCustom: '自定义 / 其他 MCP 服务',
|
|
69
69
|
composerOpen: '连接器',
|
|
70
70
|
composerNone: '当前会话未启用任何连接器',
|
|
71
|
-
|
|
71
|
+
selectAll: '全选',
|
|
72
|
+
deselectAll: '全部取消',
|
|
72
73
|
loadFailed: '加载失败',
|
|
73
74
|
retry: '重试',
|
|
74
75
|
hint: '工具将以 mcp__<标识>__<工具名> 出现在会话中。',
|
|
@@ -125,7 +126,8 @@ window.__ModuleLoader__.load({
|
|
|
125
126
|
presetCustom: 'Custom MCP server',
|
|
126
127
|
composerOpen: 'Connectors',
|
|
127
128
|
composerNone: 'No connector enabled in this conversation',
|
|
128
|
-
|
|
129
|
+
selectAll: 'Select all',
|
|
130
|
+
deselectAll: 'Deselect all',
|
|
129
131
|
loadFailed: 'Failed to load',
|
|
130
132
|
retry: 'Retry',
|
|
131
133
|
hint: 'Tools appear as mcp__<server>__<tool> in conversations.',
|
|
@@ -631,12 +633,26 @@ window.__ModuleLoader__.load({
|
|
|
631
633
|
const next = new Set(chosen);
|
|
632
634
|
if (next.has(sn)) next.delete(sn); else next.add(sn);
|
|
633
635
|
const r = await api.setSession({ sessionId, enabled: [...next] });
|
|
634
|
-
if (r.ok)
|
|
636
|
+
if (r.ok) applySession(next);
|
|
635
637
|
};
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
638
|
+
/** 与后端 POST /session 的落盘规则保持镜像:全选时删除会话记录(=默认全启用),否则保存列表 */
|
|
639
|
+
const applySession = (nextSet) => {
|
|
640
|
+
setData((d) => {
|
|
641
|
+
const sessions = { ...(d?.sessions ?? {}) };
|
|
642
|
+
const allOn = enabledConnectors.length > 0
|
|
643
|
+
&& enabledConnectors.every((c) => nextSet.has(c.serverName));
|
|
644
|
+
if (allOn) delete sessions[sessionId];
|
|
645
|
+
else sessions[sessionId] = [...nextSet];
|
|
646
|
+
return { ...d, sessions };
|
|
647
|
+
});
|
|
648
|
+
};
|
|
649
|
+
const allOn = Boolean(chosen) && enabledConnectors.length > 0
|
|
650
|
+
&& enabledConnectors.every((c) => chosen.has(c.serverName));
|
|
651
|
+
const toggleAll = async () => {
|
|
652
|
+
if (!sessionId || !api || !chosen) return;
|
|
653
|
+
const next = allOn ? new Set() : new Set(enabledConnectors.map((c) => c.serverName));
|
|
654
|
+
const r = await api.setSession({ sessionId, enabled: [...next] });
|
|
655
|
+
if (r.ok) applySession(next);
|
|
640
656
|
};
|
|
641
657
|
|
|
642
658
|
return h('div', { className: 'mcx-composer', ref: wrapRef },
|
|
@@ -645,12 +661,6 @@ window.__ModuleLoader__.load({
|
|
|
645
661
|
type: 'button', className: 'mcx-composer-btn' + (open ? ' mcx-composer-btn-active' : ''),
|
|
646
662
|
onClick: () => setOpen((o) => !o), title: t('composerOpen'),
|
|
647
663
|
}, h(LinkIcon, { size: 12 }), h('span', null, t('composerOpen')),
|
|
648
|
-
data && enabledConnectors.length > 0 && h('span', { className: 'mcx-composer-dots', 'aria-hidden': true },
|
|
649
|
-
enabledConnectors.map((c) => h('span', {
|
|
650
|
-
key: c.id,
|
|
651
|
-
className: 'mcx-mini-dot ' + ((data.mounted ?? []).includes(c.serverName) ? 'mcx-mini-dot-on' : 'mcx-mini-dot-warn'),
|
|
652
|
-
title: (c.title || c.serverName) + ((data.mounted ?? []).includes(c.serverName) ? '' : ' · ' + t('notMounted')),
|
|
653
|
-
}))),
|
|
654
664
|
h('span', { className: 'mcx-composer-count' }, count)),
|
|
655
665
|
open && h('div', { className: 'mcx-popover' },
|
|
656
666
|
enabledConnectors.length === 0
|
|
@@ -658,7 +668,7 @@ window.__ModuleLoader__.load({
|
|
|
658
668
|
: h(React.Fragment, null,
|
|
659
669
|
h('div', { className: 'mcx-popover-head' },
|
|
660
670
|
h('span', null, t('composerOpen')),
|
|
661
|
-
h('button', { type: 'button', className: 'mcx-chipbtn', onClick:
|
|
671
|
+
h('button', { type: 'button', className: 'mcx-chipbtn', onClick: toggleAll }, t(allOn ? 'deselectAll' : 'selectAll'))),
|
|
662
672
|
enabledConnectors.map((c) => h('label', { key: c.id, className: 'mcx-popover-row' },
|
|
663
673
|
h('input', {
|
|
664
674
|
type: 'checkbox',
|
|
@@ -731,11 +741,7 @@ window.__ModuleLoader__.load({
|
|
|
731
741
|
.mcx-composer{position:relative;display:inline-flex}
|
|
732
742
|
.mcx-composer-btn{display:inline-flex;align-items:center;gap:4px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);border-radius:999px;padding:2px 10px;font-size:11px;cursor:pointer;height:24px}
|
|
733
743
|
.mcx-composer-btn:hover,.mcx-composer-btn-active{color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-brand-primary)}
|
|
734
|
-
.mcx-composer-count{font-size:10px;color:var(--dsw-alias-label-tertiary)}
|
|
735
|
-
.mcx-composer-dots{display:inline-flex;align-items:center;gap:3px;margin-left:2px}
|
|
736
|
-
.mcx-mini-dot{width:6px;height:6px;border-radius:50%;display:inline-block}
|
|
737
|
-
.mcx-mini-dot-on{background:var(--dsw-alias-state-success-primary)}
|
|
738
|
-
.mcx-mini-dot-warn{background:var(--dsw-alias-state-warn-primary)}
|
|
744
|
+
.mcx-composer-count{font-size:10px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}
|
|
739
745
|
.mcx-popover{position:absolute;bottom:calc(100% + 8px);left:0;min-width:240px;background:var(--dsw-alias-bg-overlay);border:1px solid var(--dsw-alias-border-l1);border-radius:12px;box-shadow:0 6px 24px rgba(0,0,0,.18);padding:10px;display:flex;flex-direction:column;gap:6px;z-index:1200;color:var(--dsw-alias-label-primary)}
|
|
740
746
|
.mcx-popover-head{display:flex;justify-content:space-between;align-items:center;font-size:11px;color:var(--dsw-alias-label-secondary)}
|
|
741
747
|
.mcx-popover-row{display:flex;align-items:center;gap:8px;font-size:12px;padding:4px 6px;border-radius:6px;cursor:pointer}
|