@michengai/dsh-im-connect 1.0.11 → 1.0.13
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/CHANGELOG.md +15 -0
- package/CHANGELOG.zh-CN.md +15 -0
- package/README.md +28 -3
- package/README.zh-CN.md +28 -3
- package/client.js +438 -17
- package/lib/api-base.d.ts +21 -0
- package/lib/api-base.d.ts.map +1 -0
- package/lib/api-base.js +51 -0
- package/lib/api-base.js.map +1 -0
- package/lib/channels/channel-image-download.d.ts +8 -5
- package/lib/channels/channel-image-download.d.ts.map +1 -1
- package/lib/channels/channel-image-download.js +70 -2
- package/lib/channels/channel-image-download.js.map +1 -1
- package/lib/channels/diagnostics.d.ts +1 -1
- package/lib/channels/diagnostics.d.ts.map +1 -1
- package/lib/channels/diagnostics.js +2 -2
- package/lib/channels/diagnostics.js.map +1 -1
- package/lib/channels/discord.d.ts +3 -0
- package/lib/channels/discord.d.ts.map +1 -1
- package/lib/channels/discord.js +56 -7
- package/lib/channels/discord.js.map +1 -1
- package/lib/channels/factory.d.ts.map +1 -1
- package/lib/channels/factory.js +8 -2
- package/lib/channels/factory.js.map +1 -1
- package/lib/channels/file-send.d.ts +1 -1
- package/lib/channels/file-send.d.ts.map +1 -1
- package/lib/channels/file-send.js +2 -2
- package/lib/channels/file-send.js.map +1 -1
- package/lib/channels/meta.d.ts +2 -0
- package/lib/channels/meta.d.ts.map +1 -1
- package/lib/channels/meta.js +2 -0
- package/lib/channels/meta.js.map +1 -1
- package/lib/channels/telegram.d.ts +2 -0
- package/lib/channels/telegram.d.ts.map +1 -1
- package/lib/channels/telegram.js +29 -6
- package/lib/channels/telegram.js.map +1 -1
- package/lib/client.js +523 -21
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +10 -6
- package/lib/index.js.map +1 -1
- package/lib/manager.d.ts +15 -0
- package/lib/manager.d.ts.map +1 -1
- package/lib/manager.js +221 -32
- package/lib/manager.js.map +1 -1
- package/lib/plugin-updater.d.ts +1 -0
- package/lib/plugin-updater.d.ts.map +1 -1
- package/lib/plugin-updater.js +7 -0
- package/lib/plugin-updater.js.map +1 -1
- package/package.json +5 -4
- package/src/api-base.ts +45 -0
- package/src/channels/channel-image-download.ts +83 -5
- package/src/channels/diagnostics.ts +2 -2
- package/src/channels/discord.ts +49 -7
- package/src/channels/factory.ts +8 -2
- package/src/channels/file-send.ts +2 -2
- package/src/channels/meta.ts +4 -0
- package/src/channels/telegram.ts +22 -6
- package/src/index.ts +12 -6
- package/src/manager.ts +214 -31
- package/src/plugin-update-ui.js +36 -5
- package/src/plugin-updater.ts +8 -1
package/client.js
CHANGED
|
@@ -14,6 +14,7 @@ window.__ModuleLoader__.load({
|
|
|
14
14
|
const HostMenu = primitives.Menu;
|
|
15
15
|
const HostModal = primitives.Modal;
|
|
16
16
|
const HostSegmentedTabs = primitives.SegmentedTabs;
|
|
17
|
+
const PrimitiveSwitch = primitives.Switch;
|
|
17
18
|
// 宿主 Button 由 forwardRef 包成对象,typeof 是 object,不是 function。
|
|
18
19
|
function isHostComponent(component) {
|
|
19
20
|
return typeof component === "function" || (!!component && typeof component === "object" && typeof component.render === "function");
|
|
@@ -609,9 +610,11 @@ window.__ModuleLoader__.load({
|
|
|
609
610
|
"connection.title": "本次状态检查", "connection.scope": "仅检查本机渠道运行状态,未验证平台凭据或消息收发。", "connection.checkedAt": "检查时间", "connection.receiveOn": "接收开关已开启", "connection.receiveOff": "接收开关已关闭;请在账号列表开启后再发送消息。", "connection.checking": "检查中…",
|
|
610
611
|
"connection.next.connected": "可在原聊天发送消息验证收发;私聊仍需符合准入设置。", "connection.next.connecting": "请稍后再次检查;等待扫码时请完成手机确认。", "connection.next.reconnecting": "渠道正在尝试恢复,请稍后再次检查。", "connection.next.disconnected": "请重新连接;需要扫码的渠道可重新添加绑定。", "connection.next.stopped": "请点击重新连接以启动账号。", "connection.next.error": "请尝试重新连接;仍有异常时查看本机日志。", "connection.next.unknown": "暂时无法确认状态,请稍后再检查或查看本机日志。",
|
|
611
612
|
"settings.label": "IM助理", "settings.title": "IM助理", "settings.description": "管理各渠道账号。每个账号独立选择工作区、模型和权限,配置仅保存在本机。", "settings.viewProject": "GitHub", "settings.feedback": "问题反馈",
|
|
613
|
+
"sidebar.entry.title": "侧边栏入口", "sidebar.entry.desc": "在侧栏显示即时通讯管理入口。设置里的入口不变。", "sidebar.entry.toggle": "切换侧边栏入口",
|
|
614
|
+
"update.entry.title": "在线更新", "update.entry.desc": "允许检查并在线安装即时通讯插件的新版本。关闭后隐藏更新入口。", "update.entry.toggle": "切换在线更新", "error.update.disabled": "在线更新已被禁用",
|
|
612
615
|
"settings.aria": "IM助理", "settings.publicChatNotice": "未批准用户可以发起聊天,但不能批准工具调用。", "pending.notice": "有访问请求。批准后该用户才能驱动本机助手。", "action.approve": "批准", "action.deny": "拒绝", "loading": "加载中…",
|
|
613
616
|
"account.presetUnavailable": "预设不可用", "account.presetNote": "更改后使用新会话,旧会话保留。", "action.settings": "设置", "command.dm": "私聊命令", "command.group": "群聊命令", "command.enabled": "可以执行命令", "command.disabled": "仅正常对话",
|
|
614
|
-
"account.workspace": "工作区", "account.currentWorkspace": "当前工作区", "account.selectWorkspace": "请选择工作区", "account.selectModel": "请选择模型", "account.selectPermission": "请选择权限", "account.privateAccess": "私聊准入", "account.privateApproved": "仅已批准用户", "account.privateAll": "允许所有私聊用户", "account.sendMode": "发送方式", "account.sendQueue": "排队发送", "account.sendSteer": "插话发送", "account.sendSteerNote": "插话发送会把消息作为补充指令立即交给运行中的任务;任务空闲时与排队发送相同。", "account.autoNameNote": "绑定成功后会自动生成账号名,无需手动填写。需要区分使用者时,可在账号行填写备注。", "account.defaultName": "{channel}账号 {count}",
|
|
617
|
+
"account.workspace": "工作区", "account.currentWorkspace": "当前工作区", "account.selectWorkspace": "请选择工作区", "account.selectModel": "请选择模型", "account.selectPermission": "请选择权限", "account.privateAccess": "私聊准入", "account.privateApproved": "仅已批准用户", "account.privateAll": "允许所有私聊用户", "account.sendMode": "发送方式", "account.sendQueue": "排队发送", "account.sendSteer": "插话发送", "account.sendSteerNote": "插话发送会把消息作为补充指令立即交给运行中的任务;任务空闲时与排队发送相同。", "account.autoNameNote": "绑定成功后会自动生成账号名,无需手动填写。需要区分使用者时,可在账号行填写备注。", "account.proxyMode": "网络代理", "account.proxyInherit": "跟随宿主", "account.proxyDirect": "直接连接", "account.proxyCustom": "手动配置", "account.proxyUrl": "代理地址", "account.proxyNote": "仅影响当前账号;保存后自动重连生效。", "account.proxySaved": "代理地址已保存;留空保存可保留当前地址。", "account.defaultName": "{channel}账号 {count}",
|
|
615
618
|
"account.remark": "名称备注", "account.remarkNote": "只在本机设置页区分账号,留空恢复自动名称。", "account.rename": "修改名称备注",
|
|
616
619
|
"account.count": "{count} 个账号", "account.statusProcessing": "处理中…", "account.statusNotConnected": "未连接", "account.receive": "接收消息", "account.receiveDescription": "关闭后保留账号配置,但不接收新消息", "account.removeConfirm": "确定移除这个账号?本机保存的配置和凭据将一并删除。",
|
|
617
620
|
"action.addAccount": "添加账号", "action.generateQr": "生成二维码", "action.checkConnection": "诊断连接", "action.reconnectAccount": "重新连接", "action.removeAccount": "移除接入", "status.saving": "保存中…", "status.saved": "已保存",
|
|
@@ -638,9 +641,11 @@ window.__ModuleLoader__.load({
|
|
|
638
641
|
"connection.title": "Status check result", "connection.scope": "Checks local channel runtime only. Platform credentials and message delivery have not been verified.", "connection.checkedAt": "Checked at", "connection.receiveOn": "Receiving is enabled", "connection.receiveOff": "Receiving is disabled. Enable it in the account list before sending messages.", "connection.checking": "Checking…",
|
|
639
642
|
"connection.next.connected": "Send a message in the original chat to verify delivery. Private chats still follow access settings.", "connection.next.connecting": "Check again shortly. Complete confirmation on your phone if a QR scan is pending.", "connection.next.reconnecting": "The channel is attempting to recover. Check again shortly.", "connection.next.disconnected": "Reconnect the account. QR channels may need to be added again.", "connection.next.stopped": "Select Reconnect to start the account.", "connection.next.error": "Try reconnecting. If the issue persists, check the local logs.", "connection.next.unknown": "The current state could not be confirmed. Check again later or inspect the local logs.",
|
|
640
643
|
"settings.label": "IM Assistant", "settings.title": "IM Assistant", "settings.description": "Manage accounts across channels. Each account has its own workspace, model, and permission settings, stored only on this machine.", "settings.viewProject": "GitHub", "settings.feedback": "Issues",
|
|
644
|
+
"sidebar.entry.title": "Sidebar entry", "sidebar.entry.desc": "Show IM Connect in the sidebar. The Settings entry stays either way.", "sidebar.entry.toggle": "Toggle sidebar entry",
|
|
645
|
+
"update.entry.title": "Online updates", "update.entry.desc": "Allow checking and installing new versions online. Hides the update entry when disabled.", "update.entry.toggle": "Toggle online updates", "error.update.disabled": "Online updates are disabled",
|
|
641
646
|
"settings.aria": "IM Assistant", "settings.publicChatNotice": "Unapproved users can start chats, but they cannot approve tool calls.", "pending.notice": "There are access requests. Approve a user before they can control the local assistant.", "action.approve": "Approve", "action.deny": "Deny", "loading": "Loading…",
|
|
642
647
|
"account.presetUnavailable": "Preset unavailable", "account.presetNote": "Changes start a new session; previous sessions are kept.", "action.settings": "Settings", "command.dm": "DM commands", "command.group": "Group commands", "command.enabled": "Commands enabled", "command.disabled": "Conversation only",
|
|
643
|
-
"account.workspace": "Workspace", "account.currentWorkspace": "Current workspace", "account.selectWorkspace": "Select a workspace", "account.selectModel": "Select a model", "account.selectPermission": "Select a permission", "account.privateAccess": "Private chat access", "account.privateApproved": "Approved users only", "account.privateAll": "Allow all DM users", "account.sendMode": "Send mode", "account.sendQueue": "Queue", "account.sendSteer": "Steer", "account.sendSteerNote": "Steer hands the message to the running task as additional instructions at its next step; when the task is idle it behaves like Queue.", "account.autoNameNote": "The account name is generated automatically after setup. Add a remark on the account row if you need to tell users apart.", "account.defaultName": "{channel} account {count}",
|
|
648
|
+
"account.workspace": "Workspace", "account.currentWorkspace": "Current workspace", "account.selectWorkspace": "Select a workspace", "account.selectModel": "Select a model", "account.selectPermission": "Select a permission", "account.privateAccess": "Private chat access", "account.privateApproved": "Approved users only", "account.privateAll": "Allow all DM users", "account.sendMode": "Send mode", "account.sendQueue": "Queue", "account.sendSteer": "Steer", "account.sendSteerNote": "Steer hands the message to the running task as additional instructions at its next step; when the task is idle it behaves like Queue.", "account.autoNameNote": "The account name is generated automatically after setup. Add a remark on the account row if you need to tell users apart.", "account.proxyMode": "Network proxy", "account.proxyInherit": "Follow Host", "account.proxyDirect": "Connect directly", "account.proxyCustom": "Configure manually", "account.proxyUrl": "Proxy address", "account.proxyNote": "Affects only this account. The channel reconnects automatically after saving.", "account.proxySaved": "A proxy address is saved. Leave the field blank to keep it.", "account.defaultName": "{channel} account {count}",
|
|
644
649
|
"account.remark": "Name remark", "account.remarkNote": "Shown only in settings to tell accounts apart. Leave blank to restore the automatic name.", "account.rename": "Edit name remark",
|
|
645
650
|
"account.count": "{count} accounts", "account.statusProcessing": "Processing…", "account.statusNotConnected": "Not connected", "account.receive": "Receive messages", "account.receiveDescription": "Turn this off to keep the account settings without receiving new messages", "account.removeConfirm": "Remove this account? Its saved settings and credentials will also be deleted.",
|
|
646
651
|
"action.addAccount": "Add account", "action.generateQr": "Generate QR code", "action.checkConnection": "Diagnose connection", "action.reconnectAccount": "Reconnect", "action.removeAccount": "Remove", "status.saving": "Saving…", "status.saved": "Saved",
|
|
@@ -810,6 +815,8 @@ window.__ModuleLoader__.load({
|
|
|
810
815
|
.ima-bind-modal>.ima-modal-content,.ima-account-modal>.ima-modal-content{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
|
|
811
816
|
.ima-account-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 16px;width:100%;box-sizing:border-box}
|
|
812
817
|
.ima-account-settings.compact{grid-template-columns:1fr}
|
|
818
|
+
.ima-proxy-settings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px 16px;width:100%;box-sizing:border-box}
|
|
819
|
+
.ima-proxy-settings>.ima-picker-note{grid-column:1/-1}
|
|
813
820
|
.ima-picker-field{display:flex;min-width:0;width:100%;flex-direction:column;gap:6px;box-sizing:border-box}
|
|
814
821
|
.ima-picker-field.wide,.ima-picker-note,.ima-model-effort{grid-column:1/-1}
|
|
815
822
|
.ima-model-effort{display:grid;grid-template-columns:1fr 1fr;gap:14px 16px;min-width:0;width:100%;box-sizing:border-box}
|
|
@@ -842,7 +849,7 @@ window.__ModuleLoader__.load({
|
|
|
842
849
|
.ima-btn-danger:hover:not(:disabled){color:var(--dsw-alias-state-error-primary,var(--ima-danger))!important;border-color:var(--dsw-alias-state-error-primary,var(--ima-danger))!important;background:rgba(239,68,68,.12)!important}
|
|
843
850
|
.ima-btn-danger-primary,.ima-btn-danger.ima-btn-danger-primary{background:var(--dsw-alias-state-error-primary,var(--ima-danger))!important;border-color:var(--dsw-alias-state-error-primary,var(--ima-danger))!important;color:#fff!important}
|
|
844
851
|
@container (max-width:480px){.ima-account-row{grid-template-columns:minmax(0,1fr) auto auto;gap:8px;padding:10px}.ima-account-receive>span{display:none}.ima-platform-head{padding:10px 12px}.ima-account-list{padding:0 12px 12px}}
|
|
845
|
-
|
|
852
|
+
.ima-main-panel{box-sizing:border-box;height:100%;min-height:0;overflow-y:auto;display:flex;flex-direction:column;align-items:center;padding:28px clamp(24px,4vw,48px) 48px}.ima-main-panel>*{width:100%;max-width:960px}.ima-bundle-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 0;border-bottom:0.5px solid var(--dsw-alias-border-l2)}.ima-bundle-label-box{display:flex;flex-direction:column;gap:2px;min-width:0;flex:1;text-align:left}.ima-bundle-title{font-size:13px;font-weight:500;line-height:20px;color:var(--dsw-alias-label-primary)}.ima-bundle-desc{font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary)}
|
|
846
853
|
`;
|
|
847
854
|
|
|
848
855
|
const TITLE_LINK_CSS = "@media(max-width:720px){.ima-title-row{flex-wrap:wrap}}";
|
|
@@ -943,7 +950,8 @@ window.__ModuleLoader__.load({
|
|
|
943
950
|
request.headers = Object.assign({ "content-type": "application/json" }, request.headers || {}, { "x-dsh-im-connect-client": "1" });
|
|
944
951
|
if (request.body === undefined) request.body = "{}";
|
|
945
952
|
}
|
|
946
|
-
|
|
953
|
+
const targetUrl = typeof resolveApiUrl === "function" ? resolveApiUrl(API_BASE + path) : API_BASE + path;
|
|
954
|
+
return fetch(targetUrl, request).then((r) => r.json()).then((data) => {
|
|
947
955
|
if (!request.signal?.aborted && data.ok && Array.isArray(data.groups)) updateChannelMembership(data.groups);
|
|
948
956
|
return data;
|
|
949
957
|
});
|
|
@@ -1605,7 +1613,7 @@ window.__ModuleLoader__.load({
|
|
|
1605
1613
|
)
|
|
1606
1614
|
),
|
|
1607
1615
|
hasManual && h("div", showTabs ? { className: "ima-bind-panel", id: "ima-bind-panel-manual", role: "tabpanel", "aria-labelledby": "ima-bind-tab-manual", hidden: tab !== "manual" } : null,
|
|
1608
|
-
...ch.fields.map((f) => h("label", { key: f.key, className: "ima-field" },
|
|
1616
|
+
...ch.fields.filter((f) => !f.settingsOnly).map((f) => h("label", { key: f.key, className: "ima-field" },
|
|
1609
1617
|
fieldLabel(ch, f, t),
|
|
1610
1618
|
h(Input, {
|
|
1611
1619
|
type: f.secret ? "password" : "text",
|
|
@@ -1733,8 +1741,12 @@ window.__ModuleLoader__.load({
|
|
|
1733
1741
|
if (!next) { setHint(t("error.chooseWorkspace")); return Promise.resolve(); }
|
|
1734
1742
|
if (typeof props.createWorkspace !== "function") { setHint(t("error.workspaceUnavailable")); return Promise.resolve(); }
|
|
1735
1743
|
setAddBusy(true);
|
|
1736
|
-
return Promise.resolve(props.createWorkspace({ path: next })).then((created) => {
|
|
1737
|
-
const cwdPath =
|
|
1744
|
+
return Promise.resolve().then(() => props.createWorkspace({ path: next })).then((created) => {
|
|
1745
|
+
const cwdPath = created && (created.path || created.cwd);
|
|
1746
|
+
if (typeof cwdPath !== "string" || !cwdPath.trim()) {
|
|
1747
|
+
setHint(t("error.addWorkspace"));
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1738
1750
|
update({ cwd: cwdPath });
|
|
1739
1751
|
}).catch((error) => setHint((error && error.message) || t("error.addWorkspace")))
|
|
1740
1752
|
.finally(() => setAddBusy(false));
|
|
@@ -1931,6 +1943,8 @@ window.__ModuleLoader__.load({
|
|
|
1931
1943
|
function AccountInspector({ account, catalog, permissions, agentPresets, workspaces, createWorkspace, pickDirectory, modelT, permissionT, presetT, t, onAction, onSave, busy }) {
|
|
1932
1944
|
const [modal, modalHolder] = Modal.useModal();
|
|
1933
1945
|
const [draft, setDraft] = useState(account);
|
|
1946
|
+
const [proxyModeDraft, setProxyModeDraft] = useState(account.proxyMode || "inherit");
|
|
1947
|
+
const [proxyUrlDraft, setProxyUrlDraft] = useState(account.proxyUrl || "");
|
|
1934
1948
|
const [note, setNote] = useState("");
|
|
1935
1949
|
const [checkResult, setCheckResult] = useState(null);
|
|
1936
1950
|
const [checkFailed, setCheckFailed] = useState(false);
|
|
@@ -1969,14 +1983,19 @@ window.__ModuleLoader__.load({
|
|
|
1969
1983
|
useEffect(() => {
|
|
1970
1984
|
saveSeq.current += 1;
|
|
1971
1985
|
setDraft(account);
|
|
1986
|
+
setProxyModeDraft(account.proxyMode || "inherit");
|
|
1972
1987
|
setNote("");
|
|
1973
|
-
}, [account.id, account.cwd, account.permission, account.agentPreset, account.privateAccess, account.sendMode, JSON.stringify(account.commandPermissions), account.receiveEnabled, account.assistant && account.assistant.provider, account.assistant && account.assistant.model, account.assistant && account.assistant.reasoningEffort]);
|
|
1988
|
+
}, [account.id, account.cwd, account.permission, account.agentPreset, account.privateAccess, account.sendMode, account.proxyMode, account.proxyConfigured, JSON.stringify(account.commandPermissions), account.receiveEnabled, account.assistant && account.assistant.provider, account.assistant && account.assistant.model, account.assistant && account.assistant.reasoningEffort]);
|
|
1989
|
+
useEffect(() => {
|
|
1990
|
+
setProxyUrlDraft(account.proxyUrl || "");
|
|
1991
|
+
}, [account.id, account.proxyUrl]);
|
|
1974
1992
|
const save = (patch) => {
|
|
1975
1993
|
const seq = ++saveSeq.current;
|
|
1976
1994
|
const next = { ...draft, ...patch };
|
|
1977
1995
|
setDraft(next);
|
|
1996
|
+
if (next.proxyMode) setProxyModeDraft(next.proxyMode);
|
|
1978
1997
|
setNote("status.saving");
|
|
1979
|
-
|
|
1998
|
+
const payload = {
|
|
1980
1999
|
name: next.name,
|
|
1981
2000
|
cwd: next.cwd,
|
|
1982
2001
|
provider: next.assistant.provider,
|
|
@@ -1987,7 +2006,15 @@ window.__ModuleLoader__.load({
|
|
|
1987
2006
|
sendMode: next.sendMode,
|
|
1988
2007
|
agentPreset: next.agentPreset,
|
|
1989
2008
|
commandPermissions: next.commandPermissions,
|
|
1990
|
-
}
|
|
2009
|
+
};
|
|
2010
|
+
if (account.platform === "telegram" || account.platform === "discord") {
|
|
2011
|
+
const hasProxyPatch = Object.prototype.hasOwnProperty.call(patch, "proxyMode") || Object.prototype.hasOwnProperty.call(patch, "proxyUrl");
|
|
2012
|
+
if (hasProxyPatch) {
|
|
2013
|
+
payload.proxyMode = next.proxyMode || proxyModeDraft;
|
|
2014
|
+
payload.proxyUrl = Object.prototype.hasOwnProperty.call(patch, "proxyUrl") ? patch.proxyUrl : proxyUrlDraft;
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
return onSave(account.id, payload).then((ok) => {
|
|
1991
2018
|
if (seq === saveSeq.current) setNote(ok ? "status.saved" : "error.save");
|
|
1992
2019
|
return ok;
|
|
1993
2020
|
});
|
|
@@ -2039,6 +2066,43 @@ window.__ModuleLoader__.load({
|
|
|
2039
2066
|
workspaceLabel: t("account.currentWorkspace"),
|
|
2040
2067
|
t,
|
|
2041
2068
|
}),
|
|
2069
|
+
(account.platform === "telegram" || account.platform === "discord") && h("div", { className: "ima-proxy-settings" },
|
|
2070
|
+
h("label", { className: "ima-picker-field" },
|
|
2071
|
+
h("span", { className: "ima-picker-label" }, t("account.proxyMode")),
|
|
2072
|
+
h(Select, {
|
|
2073
|
+
className: "ima-account-picker",
|
|
2074
|
+
value: proxyModeDraft,
|
|
2075
|
+
"aria-label": t("account.proxyMode"),
|
|
2076
|
+
options: [
|
|
2077
|
+
{ value: "inherit", label: t("account.proxyInherit") },
|
|
2078
|
+
{ value: "direct", label: t("account.proxyDirect") },
|
|
2079
|
+
{ value: "custom", label: t("account.proxyCustom") },
|
|
2080
|
+
],
|
|
2081
|
+
onChange: (next) => {
|
|
2082
|
+
setProxyModeDraft(next);
|
|
2083
|
+
if (next === "custom" && !account.proxyConfigured) setDraft({ ...draft, proxyMode: next });
|
|
2084
|
+
else save({ proxyMode: next, proxyUrl: "" });
|
|
2085
|
+
},
|
|
2086
|
+
})),
|
|
2087
|
+
proxyModeDraft === "custom" && h("label", { className: "ima-picker-field" },
|
|
2088
|
+
h("span", { className: "ima-picker-label" }, t("account.proxyUrl")),
|
|
2089
|
+
h(Input, {
|
|
2090
|
+
type: "text",
|
|
2091
|
+
autoComplete: "url",
|
|
2092
|
+
value: proxyUrlDraft,
|
|
2093
|
+
placeholder: t(account.proxyConfigured ? "account.proxySaved" : "http://127.0.0.1:7897"),
|
|
2094
|
+
"aria-label": t("account.proxyUrl"),
|
|
2095
|
+
onChange: (event) => { setProxyUrlDraft(event.target.value); setDraft({ ...draft, proxyMode: "custom" }); },
|
|
2096
|
+
onBlur: (event) => {
|
|
2097
|
+
const value = event.target.value.trim();
|
|
2098
|
+
save({ proxyMode: "custom", proxyUrl: value }).then((ok) => {
|
|
2099
|
+
if (ok && !value) setProxyUrlDraft(account.proxyUrl || "");
|
|
2100
|
+
});
|
|
2101
|
+
},
|
|
2102
|
+
}),
|
|
2103
|
+
),
|
|
2104
|
+
h("div", { className: "ima-picker-note" }, t("account.proxyNote")),
|
|
2105
|
+
),
|
|
2042
2106
|
h(CommandPermissionSettings, { value: draft.commandPermissions, onSave: commandPermissions => save({ commandPermissions }), t }),
|
|
2043
2107
|
note && h("div", { className: note === "status.saved" ? "ima-save-note ok" : "ima-save-note" }, t(note)),
|
|
2044
2108
|
h("div", { className: "ima-inspector-actions" },
|
|
@@ -3246,19 +3310,33 @@ window.__ModuleLoader__.load({
|
|
|
3246
3310
|
}
|
|
3247
3311
|
openListed(id);
|
|
3248
3312
|
};
|
|
3313
|
+
const safeExpandSidebar = useCallback(() => {}, []);
|
|
3314
|
+
const rawUseWorkspaceShortcuts = typeof props.useWorkspaceShortcuts === "function" ? props.useWorkspaceShortcuts : undefined;
|
|
3315
|
+
const useIsolatedWorkspaceShortcuts = useCallback((select, equals) => {
|
|
3316
|
+
if (typeof rawUseWorkspaceShortcuts !== "function") return select({ searchRequest: 0, addRequested: false, directoryBusy: false, renameTarget: null });
|
|
3317
|
+
return rawUseWorkspaceShortcuts((state) => select(Object.assign({}, state, { searchRequest: 0 })), equals);
|
|
3318
|
+
}, [rawUseWorkspaceShortcuts]);
|
|
3319
|
+
const guardedHostProps = Object.assign({}, props, {
|
|
3320
|
+
expandSidebar: safeExpandSidebar,
|
|
3321
|
+
useWorkspaceShortcuts: useIsolatedWorkspaceShortcuts,
|
|
3322
|
+
});
|
|
3249
3323
|
const officialProps = Object.assign({}, props, { useSessions: useTaskSessions, t: officialT, openSession, open: openSession });
|
|
3324
|
+
const guardedOfficialProps = Object.assign({}, officialProps, {
|
|
3325
|
+
expandSidebar: safeExpandSidebar,
|
|
3326
|
+
useWorkspaceShortcuts: useIsolatedWorkspaceShortcuts,
|
|
3327
|
+
});
|
|
3250
3328
|
const channelView = h(ChannelOfficialView, {
|
|
3251
3329
|
officialTree: Official,
|
|
3252
|
-
hostProps:
|
|
3330
|
+
hostProps: guardedHostProps,
|
|
3253
3331
|
hostT: officialT,
|
|
3254
3332
|
t,
|
|
3255
3333
|
openSession,
|
|
3256
3334
|
openChannelSettings: props.openChannelSettings,
|
|
3257
3335
|
openImSettings: props.openImSettings,
|
|
3258
3336
|
});
|
|
3259
|
-
if (props.wide === false) return Official ? h(Official,
|
|
3337
|
+
if (props.wide === false) return Official ? h(Official, guardedOfficialProps) : null;
|
|
3260
3338
|
const officialTree = Official
|
|
3261
|
-
? h("div", { className: "ima-official-tree" }, h(Official,
|
|
3339
|
+
? h("div", { className: "ima-official-tree" }, h(Official, guardedOfficialProps))
|
|
3262
3340
|
: null;
|
|
3263
3341
|
const visibleTab = resolveSidebarTab(tab, extraTabs);
|
|
3264
3342
|
const extra = extraTabs.find((item) => item.id === visibleTab);
|
|
@@ -3409,6 +3487,330 @@ window.__ModuleLoader__.load({
|
|
|
3409
3487
|
|| component.__dshAutomationOriginal !== undefined);
|
|
3410
3488
|
}
|
|
3411
3489
|
|
|
3490
|
+
const BUNDLE_KEY = "@michengai/dsh-im-connect";
|
|
3491
|
+
const SIDEBAR_PANEL_ID = "im-connect";
|
|
3492
|
+
const SIDEBAR_PANEL_ORDER = 3;
|
|
3493
|
+
|
|
3494
|
+
function ImSidebarIcon(props) {
|
|
3495
|
+
const size = props && typeof props.size === "number" ? props.size : 16;
|
|
3496
|
+
return h(IconQueueOutline, { size });
|
|
3497
|
+
}
|
|
3498
|
+
|
|
3499
|
+
function ImBundleConfigCard(props) {
|
|
3500
|
+
const {
|
|
3501
|
+
t,
|
|
3502
|
+
enabled,
|
|
3503
|
+
onToggle,
|
|
3504
|
+
disabled,
|
|
3505
|
+
onlineUpdateEnabled = true,
|
|
3506
|
+
onToggleOnlineUpdate,
|
|
3507
|
+
onlineUpdateDisabled,
|
|
3508
|
+
onlineUpdateLocked = false,
|
|
3509
|
+
} = props;
|
|
3510
|
+
|
|
3511
|
+
const SwitchComponent = PrimitiveSwitch || Switch;
|
|
3512
|
+
const rows = [
|
|
3513
|
+
h("div", { key: "sidebar-entry", className: "ima-bundle-row" },
|
|
3514
|
+
h("div", { className: "ima-bundle-label-box" },
|
|
3515
|
+
h("span", { className: "ima-bundle-title" }, t("sidebar.entry.title")),
|
|
3516
|
+
h("span", { className: "ima-bundle-desc" }, t("sidebar.entry.desc"))
|
|
3517
|
+
),
|
|
3518
|
+
h(SwitchComponent, {
|
|
3519
|
+
checked: enabled,
|
|
3520
|
+
onChange: onToggle,
|
|
3521
|
+
label: t("sidebar.entry.toggle"),
|
|
3522
|
+
disabled: disabled,
|
|
3523
|
+
})
|
|
3524
|
+
),
|
|
3525
|
+
];
|
|
3526
|
+
|
|
3527
|
+
if (typeof onToggleOnlineUpdate === "function") {
|
|
3528
|
+
const updateDesc = onlineUpdateLocked
|
|
3529
|
+
? `${t("update.entry.desc")} (${t("error.update.disabled")})`
|
|
3530
|
+
: t("update.entry.desc");
|
|
3531
|
+
rows.push(
|
|
3532
|
+
h("div", { key: "online-update", className: "ima-bundle-row" },
|
|
3533
|
+
h("div", { className: "ima-bundle-label-box" },
|
|
3534
|
+
h("span", { className: "ima-bundle-title" }, t("update.entry.title")),
|
|
3535
|
+
h("span", { className: "ima-bundle-desc" }, updateDesc)
|
|
3536
|
+
),
|
|
3537
|
+
h(SwitchComponent, {
|
|
3538
|
+
checked: onlineUpdateEnabled,
|
|
3539
|
+
onChange: onToggleOnlineUpdate,
|
|
3540
|
+
label: t("update.entry.toggle"),
|
|
3541
|
+
disabled: onlineUpdateDisabled || onlineUpdateLocked,
|
|
3542
|
+
})
|
|
3543
|
+
)
|
|
3544
|
+
);
|
|
3545
|
+
}
|
|
3546
|
+
|
|
3547
|
+
return h(React.Fragment, null, rows);
|
|
3548
|
+
}
|
|
3549
|
+
|
|
3550
|
+
function ImBundleConfigCardWrapper(props) {
|
|
3551
|
+
const [enabled, setEnabled] = useState(props.getEnabled);
|
|
3552
|
+
const [onlineUpdateEnabled, setOnlineUpdateEnabled] = useState(props.getOnlineUpdateEnabled ? props.getOnlineUpdateEnabled : () => true);
|
|
3553
|
+
const [onlineUpdateLocked, setOnlineUpdateLocked] = useState(props.getOnlineUpdateLocked ? props.getOnlineUpdateLocked : () => false);
|
|
3554
|
+
const [savingSidebar, setSavingSidebar] = useState(false);
|
|
3555
|
+
const [savingUpdate, setSavingUpdate] = useState(false);
|
|
3556
|
+
|
|
3557
|
+
useEffect(() => {
|
|
3558
|
+
setEnabled(props.getEnabled());
|
|
3559
|
+
if (props.getOnlineUpdateEnabled) {
|
|
3560
|
+
setOnlineUpdateEnabled(props.getOnlineUpdateEnabled());
|
|
3561
|
+
}
|
|
3562
|
+
if (props.getOnlineUpdateLocked) {
|
|
3563
|
+
setOnlineUpdateLocked(props.getOnlineUpdateLocked());
|
|
3564
|
+
}
|
|
3565
|
+
return props.subscribe(() => {
|
|
3566
|
+
setEnabled(props.getEnabled());
|
|
3567
|
+
if (props.getOnlineUpdateEnabled) {
|
|
3568
|
+
setOnlineUpdateEnabled(props.getOnlineUpdateEnabled());
|
|
3569
|
+
}
|
|
3570
|
+
if (props.getOnlineUpdateLocked) {
|
|
3571
|
+
setOnlineUpdateLocked(props.getOnlineUpdateLocked());
|
|
3572
|
+
}
|
|
3573
|
+
});
|
|
3574
|
+
}, [props]);
|
|
3575
|
+
|
|
3576
|
+
const onToggleSidebar = (next) => {
|
|
3577
|
+
setSavingSidebar(true);
|
|
3578
|
+
setEnabled(next);
|
|
3579
|
+
props.setSidebar(next).catch(() => {
|
|
3580
|
+
setEnabled(props.getEnabled());
|
|
3581
|
+
}).finally(() => {
|
|
3582
|
+
setSavingSidebar(false);
|
|
3583
|
+
});
|
|
3584
|
+
};
|
|
3585
|
+
|
|
3586
|
+
const onToggleOnlineUpdate = props.setOnlineUpdate ? (next) => {
|
|
3587
|
+
if (onlineUpdateLocked) return;
|
|
3588
|
+
setSavingUpdate(true);
|
|
3589
|
+
setOnlineUpdateEnabled(next);
|
|
3590
|
+
props.setOnlineUpdate(next).catch(() => {
|
|
3591
|
+
if (props.getOnlineUpdateEnabled) {
|
|
3592
|
+
setOnlineUpdateEnabled(props.getOnlineUpdateEnabled());
|
|
3593
|
+
}
|
|
3594
|
+
}).finally(() => {
|
|
3595
|
+
setSavingUpdate(false);
|
|
3596
|
+
});
|
|
3597
|
+
} : undefined;
|
|
3598
|
+
|
|
3599
|
+
return h(ImBundleConfigCard, {
|
|
3600
|
+
t: props.t,
|
|
3601
|
+
enabled,
|
|
3602
|
+
disabled: savingSidebar,
|
|
3603
|
+
onToggle: onToggleSidebar,
|
|
3604
|
+
onlineUpdateEnabled,
|
|
3605
|
+
onlineUpdateDisabled: savingUpdate,
|
|
3606
|
+
onlineUpdateLocked,
|
|
3607
|
+
onToggleOnlineUpdate,
|
|
3608
|
+
});
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
function setupSidebarEntry(ctx, options) {
|
|
3612
|
+
if (!ctx.locale) {
|
|
3613
|
+
return {
|
|
3614
|
+
isEnabled: () => false,
|
|
3615
|
+
isSupported: () => false,
|
|
3616
|
+
setEnabled: async () => false,
|
|
3617
|
+
isOnlineUpdateEnabled: () => true,
|
|
3618
|
+
setOnlineUpdate: async () => false,
|
|
3619
|
+
destroy: () => {},
|
|
3620
|
+
};
|
|
3621
|
+
}
|
|
3622
|
+
const { callApi, renderPanel, ns } = options;
|
|
3623
|
+
let sidebarEntryEnabled = false;
|
|
3624
|
+
let sidebarSupported = false;
|
|
3625
|
+
let offPanel = null;
|
|
3626
|
+
let offRow = null;
|
|
3627
|
+
let epoch = 0;
|
|
3628
|
+
let layoutService;
|
|
3629
|
+
const listeners = new Set();
|
|
3630
|
+
|
|
3631
|
+
const notify = () => {
|
|
3632
|
+
for (const listener of listeners) {
|
|
3633
|
+
try { listener(); } catch {}
|
|
3634
|
+
}
|
|
3635
|
+
};
|
|
3636
|
+
|
|
3637
|
+
const sync = () => {
|
|
3638
|
+
if (sidebarSupported && sidebarEntryEnabled) {
|
|
3639
|
+
if (!offPanel) {
|
|
3640
|
+
const res = ctx.slots.register({
|
|
3641
|
+
name: "main",
|
|
3642
|
+
key: SIDEBAR_PANEL_ID,
|
|
3643
|
+
locale: ns,
|
|
3644
|
+
inject: () => {
|
|
3645
|
+
const extra = typeof options.injectProps === "function" ? options.injectProps() : options.injectProps;
|
|
3646
|
+
return Object.assign({ t: ctx.locale?.bind ? ctx.locale.bind(ns) : undefined }, extra);
|
|
3647
|
+
},
|
|
3648
|
+
}, (ownerProps) => h("div", { className: "ima-main-panel" }, renderPanel(ownerProps)));
|
|
3649
|
+
offPanel = typeof res === "function" ? res : () => {};
|
|
3650
|
+
}
|
|
3651
|
+
if (!offRow) {
|
|
3652
|
+
const res = ctx.slots.register({
|
|
3653
|
+
name: "sidebar.panellist",
|
|
3654
|
+
id: SIDEBAR_PANEL_ID,
|
|
3655
|
+
order: SIDEBAR_PANEL_ORDER,
|
|
3656
|
+
label: () => ctx.locale.bind(ns)("settings.title"),
|
|
3657
|
+
locale: ns,
|
|
3658
|
+
}, (ownerProps) => h(ImSidebarIcon, ownerProps));
|
|
3659
|
+
offRow = typeof res === "function" ? res : () => {};
|
|
3660
|
+
}
|
|
3661
|
+
} else {
|
|
3662
|
+
if (layoutService?.panelInfo && typeof layoutService.selectPanel === "function") {
|
|
3663
|
+
try {
|
|
3664
|
+
if (layoutService.panelInfo.getSnapshot().activePanelId === SIDEBAR_PANEL_ID) {
|
|
3665
|
+
layoutService.selectPanel(null);
|
|
3666
|
+
}
|
|
3667
|
+
} catch {}
|
|
3668
|
+
}
|
|
3669
|
+
if (offRow) {
|
|
3670
|
+
try { offRow(); } catch {}
|
|
3671
|
+
offRow = null;
|
|
3672
|
+
}
|
|
3673
|
+
if (offPanel) {
|
|
3674
|
+
try { offPanel(); } catch {}
|
|
3675
|
+
offPanel = null;
|
|
3676
|
+
}
|
|
3677
|
+
}
|
|
3678
|
+
};
|
|
3679
|
+
|
|
3680
|
+
const setEnabled = async (next) => {
|
|
3681
|
+
const currentEpoch = ++epoch;
|
|
3682
|
+
sidebarEntryEnabled = next;
|
|
3683
|
+
sync();
|
|
3684
|
+
notify();
|
|
3685
|
+
try {
|
|
3686
|
+
await callApi("/sidebar-entry", {
|
|
3687
|
+
method: "POST",
|
|
3688
|
+
body: JSON.stringify({ enabled: next }),
|
|
3689
|
+
});
|
|
3690
|
+
return next;
|
|
3691
|
+
} catch (err) {
|
|
3692
|
+
if (currentEpoch === epoch) {
|
|
3693
|
+
sidebarEntryEnabled = !next;
|
|
3694
|
+
sync();
|
|
3695
|
+
notify();
|
|
3696
|
+
}
|
|
3697
|
+
throw err;
|
|
3698
|
+
}
|
|
3699
|
+
};
|
|
3700
|
+
|
|
3701
|
+
let onlineUpdateEnabled = true;
|
|
3702
|
+
let onlineUpdateLocked = false;
|
|
3703
|
+
let updateEpoch = 0;
|
|
3704
|
+
|
|
3705
|
+
const setOnlineUpdate = async (next) => {
|
|
3706
|
+
if (onlineUpdateLocked) return onlineUpdateEnabled;
|
|
3707
|
+
const currentEpoch = ++updateEpoch;
|
|
3708
|
+
onlineUpdateEnabled = next;
|
|
3709
|
+
notify();
|
|
3710
|
+
if (typeof options.onOnlineUpdateChange === "function") {
|
|
3711
|
+
try { options.onOnlineUpdateChange(next); } catch {}
|
|
3712
|
+
}
|
|
3713
|
+
try {
|
|
3714
|
+
await callApi("/online-update", {
|
|
3715
|
+
method: "POST",
|
|
3716
|
+
body: JSON.stringify({ enabled: next }),
|
|
3717
|
+
});
|
|
3718
|
+
// 乐观通知可能早于服务端开启;保存完成后再通知更新器重读版本。
|
|
3719
|
+
if (currentEpoch === updateEpoch && typeof options.onOnlineUpdateChange === "function") {
|
|
3720
|
+
options.onOnlineUpdateChange(next);
|
|
3721
|
+
}
|
|
3722
|
+
return next;
|
|
3723
|
+
} catch (err) {
|
|
3724
|
+
if (currentEpoch === updateEpoch) {
|
|
3725
|
+
onlineUpdateEnabled = !next;
|
|
3726
|
+
notify();
|
|
3727
|
+
if (typeof options.onOnlineUpdateChange === "function") {
|
|
3728
|
+
try { options.onOnlineUpdateChange(!next); } catch {}
|
|
3729
|
+
}
|
|
3730
|
+
}
|
|
3731
|
+
throw err;
|
|
3732
|
+
}
|
|
3733
|
+
};
|
|
3734
|
+
|
|
3735
|
+
const loadEpoch = epoch;
|
|
3736
|
+
callApi("/sidebar-entry")
|
|
3737
|
+
.then((res) => {
|
|
3738
|
+
if (epoch === loadEpoch && res && typeof res.enabled === "boolean") {
|
|
3739
|
+
sidebarEntryEnabled = res.enabled;
|
|
3740
|
+
sync();
|
|
3741
|
+
notify();
|
|
3742
|
+
}
|
|
3743
|
+
})
|
|
3744
|
+
.catch(() => {});
|
|
3745
|
+
|
|
3746
|
+
const loadUpdateEpoch = updateEpoch;
|
|
3747
|
+
callApi("/online-update")
|
|
3748
|
+
.then((res) => {
|
|
3749
|
+
if (updateEpoch === loadUpdateEpoch && res) {
|
|
3750
|
+
if (typeof res.enabled === "boolean") onlineUpdateEnabled = res.enabled;
|
|
3751
|
+
if (typeof res.locked === "boolean") onlineUpdateLocked = res.locked;
|
|
3752
|
+
notify();
|
|
3753
|
+
if (typeof options.onOnlineUpdateChange === "function") {
|
|
3754
|
+
try { options.onOnlineUpdateChange(onlineUpdateEnabled); } catch {}
|
|
3755
|
+
}
|
|
3756
|
+
}
|
|
3757
|
+
})
|
|
3758
|
+
.catch(() => {});
|
|
3759
|
+
|
|
3760
|
+
if (typeof ctx.inject === "function") {
|
|
3761
|
+
ctx.inject(["layout"], (scoped) => {
|
|
3762
|
+
layoutService = scoped.layout;
|
|
3763
|
+
});
|
|
3764
|
+
}
|
|
3765
|
+
|
|
3766
|
+
ctx.slots.inject("sidebar.panellist", () => {
|
|
3767
|
+
sidebarSupported = true;
|
|
3768
|
+
sync();
|
|
3769
|
+
});
|
|
3770
|
+
|
|
3771
|
+
ctx.slots.inject("plugins.bundle.config", () => {
|
|
3772
|
+
return ctx.slots.register({
|
|
3773
|
+
name: "plugins.bundle.config",
|
|
3774
|
+
key: BUNDLE_KEY,
|
|
3775
|
+
locale: ns,
|
|
3776
|
+
}, (ownerProps) => {
|
|
3777
|
+
if (ownerProps && ownerProps.view === "summary") return null;
|
|
3778
|
+
return h(ImBundleConfigCardWrapper, {
|
|
3779
|
+
t: ctx.locale.bind(ns),
|
|
3780
|
+
getEnabled: () => sidebarEntryEnabled,
|
|
3781
|
+
setSidebar: setEnabled,
|
|
3782
|
+
getOnlineUpdateEnabled: () => onlineUpdateEnabled,
|
|
3783
|
+
getOnlineUpdateLocked: () => onlineUpdateLocked,
|
|
3784
|
+
setOnlineUpdate: setOnlineUpdate,
|
|
3785
|
+
subscribe: (fn) => {
|
|
3786
|
+
listeners.add(fn);
|
|
3787
|
+
return () => { listeners.delete(fn); };
|
|
3788
|
+
},
|
|
3789
|
+
});
|
|
3790
|
+
});
|
|
3791
|
+
});
|
|
3792
|
+
|
|
3793
|
+
return {
|
|
3794
|
+
isEnabled: () => sidebarEntryEnabled,
|
|
3795
|
+
isSupported: () => sidebarSupported,
|
|
3796
|
+
setEnabled,
|
|
3797
|
+
isOnlineUpdateEnabled: () => onlineUpdateEnabled,
|
|
3798
|
+
isOnlineUpdateLocked: () => onlineUpdateLocked,
|
|
3799
|
+
setOnlineUpdate,
|
|
3800
|
+
destroy: () => {
|
|
3801
|
+
listeners.clear();
|
|
3802
|
+
if (offRow) {
|
|
3803
|
+
try { offRow(); } catch {}
|
|
3804
|
+
offRow = null;
|
|
3805
|
+
}
|
|
3806
|
+
if (offPanel) {
|
|
3807
|
+
try { offPanel(); } catch {}
|
|
3808
|
+
offPanel = null;
|
|
3809
|
+
}
|
|
3810
|
+
},
|
|
3811
|
+
};
|
|
3812
|
+
}
|
|
3813
|
+
|
|
3412
3814
|
function apply(ctx) {
|
|
3413
3815
|
ensureStyle();
|
|
3414
3816
|
ctx.effect(() => {
|
|
@@ -3441,6 +3843,25 @@ window.__ModuleLoader__.load({
|
|
|
3441
3843
|
}), "im-connect: channel membership");
|
|
3442
3844
|
ctx.effect(() => ctx.locale.register(IM_LOCALE_NS, IM_LOCALES), "im-connect: dictionaries");
|
|
3443
3845
|
const t = ctx.locale.bind(IM_LOCALE_NS);
|
|
3846
|
+
const permissionT = ctx.locale.bind("permission.access");
|
|
3847
|
+
const modelT = ctx.locale.bind("model");
|
|
3848
|
+
const presetT = ctx.locale.bind("settings.agentPreset");
|
|
3849
|
+
const sidebarController = setupSidebarEntry(ctx, {
|
|
3850
|
+
callApi: api,
|
|
3851
|
+
renderPanel: (ownerProps) => h(LocalizedSettingsPage, ownerProps),
|
|
3852
|
+
ns: IM_LOCALE_NS,
|
|
3853
|
+
injectProps: () => ({
|
|
3854
|
+
createWorkspace: typeof ctx.workspaces?.create === "function" ? (input) => ctx.workspaces.create(input) : undefined,
|
|
3855
|
+
pickDirectory: () => pickHostDirectory(ctx),
|
|
3856
|
+
permissionT,
|
|
3857
|
+
modelT,
|
|
3858
|
+
presetT,
|
|
3859
|
+
}),
|
|
3860
|
+
onOnlineUpdateChange: () => {
|
|
3861
|
+
if (typeof window !== "undefined") window.dispatchEvent(new CustomEvent("ima-update-toggle"));
|
|
3862
|
+
},
|
|
3863
|
+
});
|
|
3864
|
+
ctx.effect(() => () => sidebarController.destroy(), "im-connect: sidebar entry");
|
|
3444
3865
|
ctx.effect(() => observePluginUpdate({
|
|
3445
3866
|
endpoint: "/api/michengai/dsh-im-connect/update",
|
|
3446
3867
|
packageName: "@michengai/dsh-im-connect",
|
|
@@ -3449,10 +3870,8 @@ window.__ModuleLoader__.load({
|
|
|
3449
3870
|
zhName: t("settings.title"),
|
|
3450
3871
|
enName: t("settings.title"),
|
|
3451
3872
|
createIcon: createPluginUpdateIcon,
|
|
3873
|
+
isEnabled: () => sidebarController.isOnlineUpdateEnabled(),
|
|
3452
3874
|
}), "im-connect: plugin update ui");
|
|
3453
|
-
const permissionT = ctx.locale.bind("permission.access");
|
|
3454
|
-
const modelT = ctx.locale.bind("model");
|
|
3455
|
-
const presetT = ctx.locale.bind("settings.agentPreset");
|
|
3456
3875
|
const subscribeLocale = (listener) => ctx.locale.subscribe(listener);
|
|
3457
3876
|
const localeSnapshot = () => ctx.locale.getSnapshot();
|
|
3458
3877
|
const openChannelSettings = (request) => {
|
|
@@ -3576,7 +3995,7 @@ window.__ModuleLoader__.load({
|
|
|
3576
3995
|
icon: "chat",
|
|
3577
3996
|
locale: IM_LOCALE_NS,
|
|
3578
3997
|
inject: () => ({
|
|
3579
|
-
createWorkspace: (input) => ctx.workspaces.create(input),
|
|
3998
|
+
createWorkspace: typeof ctx.workspaces?.create === "function" ? (input) => ctx.workspaces.create(input) : undefined,
|
|
3580
3999
|
pickDirectory: () => pickHostDirectory(ctx),
|
|
3581
4000
|
permissionT,
|
|
3582
4001
|
modelT,
|
|
@@ -3760,6 +4179,8 @@ window.__ModuleLoader__.load({
|
|
|
3760
4179
|
|
|
3761
4180
|
exports.apply = apply;
|
|
3762
4181
|
exports.inject = inject;
|
|
4182
|
+
exports.resolveApiUrl = resolveApiUrl;
|
|
4183
|
+
exports.setupSidebarEntry = setupSidebarEntry;
|
|
3763
4184
|
return module.exports;
|
|
3764
4185
|
},
|
|
3765
4186
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API 基址解析:把插件自己的根绝对路径端点解析到页面实际所在的 base 之下。
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要:DSH 可能被挂在带路径前缀的反向代理后面(例如 https://host/app/dsh/,
|
|
5
|
+
* 网关转发前剥掉前缀)。此时浏览器把根绝对路径 "/api/..." 解析到站点根,前缀丢失,
|
|
6
|
+
* 网关返回自己的 HTML 404,面板就报「服务端返回非 JSON 响应(HTTP 404)」。
|
|
7
|
+
*
|
|
8
|
+
* 为什么这么解析:宿主前端同样以页面 base 解析 API 路径(参见 dsh-client-connection 的
|
|
9
|
+
* openConnectionWebSocket 与 dsh-client-file-upload 的 new URL(path, document.baseURI)),
|
|
10
|
+
* 这里沿用同一约定——先去掉前导 "/",再用 new URL 相对解析;若直接 new URL("/api/x", base)
|
|
11
|
+
* 会丢弃 base 的路径段,前缀就没了。
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* 解析插件端点 URL。
|
|
15
|
+
*
|
|
16
|
+
* @param path 端点路径,通常是 "/api/dsh-im-connect/xxx" 这类根绝对路径。
|
|
17
|
+
* @returns 基于页面 base 的绝对 URL;相对路径、完整 URL、协议相对 URL、无 document
|
|
18
|
+
* 或 base 非法时原样返回,保证非浏览器环境与测试夹具行为不变。
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveApiUrl(path: string): string;
|
|
21
|
+
//# sourceMappingURL=api-base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api-base.d.ts","sourceRoot":"","sources":["../src/api-base.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAiBH;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASlD"}
|