@michengai/dsh-im-connect 1.0.12 → 1.0.14
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 +7 -1
- package/CHANGELOG.zh-CN.md +7 -1
- package/README.md +28 -3
- package/README.zh-CN.md +28 -3
- package/client.js +378 -11
- 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/feishu.d.ts.map +1 -1
- package/lib/channels/feishu.js +39 -1
- package/lib/channels/feishu.js.map +1 -1
- package/lib/client.js +463 -15
- 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 +7 -0
- package/lib/manager.d.ts.map +1 -1
- package/lib/manager.js +75 -0
- 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 +1 -1
- package/src/api-base.ts +45 -0
- package/src/channels/feishu.ts +35 -2
- package/src/index.ts +12 -6
- package/src/manager.ts +78 -1
- package/src/plugin-update-ui.js +36 -5
- package/src/plugin-updater.ts +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 1.0.
|
|
3
|
+
## 1.0.14 - 2026-10-23
|
|
4
|
+
|
|
5
|
+
- Deliver outbound images on Feishu / Lark as real image messages: upload through `im/v1/images` with `image_type=message`, then send with `msg_type=image` so pictures render inline instead of arriving as file attachments (PR #47).
|
|
6
|
+
- Route by extension and size: only PNG/JPG/JPEG/WEBP/GIF/BMP/ICO/TIFF/HEIC up to 10 MB use image messages; larger files and non-images keep the existing file path.
|
|
7
|
+
- Fall back to a file message when the image upload or send is rejected by the platform so the picture is never lost; an explicit cancellation or timeout still aborts instead of silently re-sending.
|
|
8
|
+
|
|
9
|
+
## 1.0.13 - 2026-10-23
|
|
4
10
|
|
|
5
11
|
- Support per-account outbound proxy configuration for Telegram and Discord: choose between following host proxy (default), connecting directly, or configuring custom HTTP/HTTPS proxies.
|
|
6
12
|
- Route all Telegram and Discord outbound traffic through the configured proxy, including REST APIs, Telegram long polling, Discord Gateway WebSocket connections, file transfers, connection diagnostics, and inbound media/attachment downloads.
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
以下记录近期发布的版本。Git 标签与 GitHub Release 现已和这些条目同步;历史条目继续保留原始发布提交链接。
|
|
6
6
|
|
|
7
|
-
## 1.0.
|
|
7
|
+
## 1.0.14 - 2026-10-23
|
|
8
|
+
|
|
9
|
+
- 飞书 / Lark 回传图片时改用图片消息:先调 `im/v1/images` 上传(`image_type=message`),再以 `msg_type=image` 发送,聊天中直接内联预览,不再以文件形式出现(PR #47)。
|
|
10
|
+
- 图片按扩展名与大小分流:PNG/JPG/JPEG/WEBP/GIF/BMP/ICO/TIFF/HEIC 且不超过 10 MB 才走图片消息;超过 10 MB 或非图片仍按文件发送。
|
|
11
|
+
- 图片上传或发送被平台拒绝时自动回落为文件消息,图片不会丢失;主动取消或超时仍然中断,不静默重发。
|
|
12
|
+
|
|
13
|
+
## 1.0.13 - 2026-10-23
|
|
8
14
|
|
|
9
15
|
- 支持 Telegram 与 Discord 按账号独立配置出站代理:可在账号设置中选择跟随宿主(默认)、直连或手动配置 HTTP/HTTPS 代理。
|
|
10
16
|
- 覆盖全链路出站代理分流:包含 REST Web API、Telegram 长轮询、Discord Gateway WebSocket 连接与重连、文件发送、连接诊断以及入站图片和附件下载。
|
package/README.md
CHANGED
|
@@ -205,6 +205,7 @@ For a desktop workbench, download [DSH Codex Desktop](https://github.com/Micheng
|
|
|
205
205
|
- Examples use the `web` profile; replace it with the target profile.
|
|
206
206
|
- Source installation and development require Node.js 22+. npm installation does not require running `npm install` in an arbitrary directory.
|
|
207
207
|
- After install, restart `dsh web` and hard-refresh the browser before opening **Settings → IM Assistant**.
|
|
208
|
+
- **Reverse proxy deployment**: Supports hosting DSH behind prefix-stripping reverse proxies (e.g. `/app/dsh/`). API and update endpoints automatically resolve against the page base URI (`document.baseURI`), preventing 404 errors caused by lost prefix segments.
|
|
208
209
|
|
|
209
210
|
## Installation
|
|
210
211
|
|
|
@@ -233,9 +234,33 @@ To pin a release, replace `@latest` with a version such as `@0.1.28`.
|
|
|
233
234
|
|
|
234
235
|
The configuration output should contain `im-connect`. Restart DSH Web and hard-refresh the browser. Do not copy client files manually: `dsh plugin add` also applies `cordis.patch.yml`.
|
|
235
236
|
|
|
236
|
-
##
|
|
237
|
-
|
|
238
|
-
The
|
|
237
|
+
## Plugin Configuration & Toggles
|
|
238
|
+
|
|
239
|
+
The plugin follows standard DSH bundle configuration conventions. Options are located at:
|
|
240
|
+
> **Sidebar → Plugins → Click `@michengai/dsh-im-connect`** (the host's `plugins.bundle.config` slot).
|
|
241
|
+
|
|
242
|
+
Two native switches are available. Their values are persisted in `channels.json` under the plugin's `stateDir` and survive restarts; they are not two equivalent Cordis YAML options. `sidebarEntry` is managed through this UI, while `onlineUpdate` is also subject to the host lock described below:
|
|
243
|
+
|
|
244
|
+
### 1. Sidebar Entry (`sidebarEntry`)
|
|
245
|
+
- **Default**: Disabled (`false`)
|
|
246
|
+
- **Description**: Displays a persistent **IM Connect** navigation icon in the host's left primary sidebar.
|
|
247
|
+
- **Effect**:
|
|
248
|
+
- When enabled, clicking the sidebar icon opens the IM Assistant management page directly in the primary workspace with a **960px centered container** (matching host plugin manager conventions). This eliminates vertical scrolling constraints in narrow settings dialogs;
|
|
249
|
+
- When disabled, unregisters the sidebar entry cleanly (and resets active panel gracefully if currently viewing the panel, preventing blank views);
|
|
250
|
+
- The standard **Settings → IM Assistant** view remains active either way, and state is synchronized live across both entry points.
|
|
251
|
+
|
|
252
|
+
### 2. Online Updates (`onlineUpdate` / `updater`)
|
|
253
|
+
- **Default**: Enabled (`true`)
|
|
254
|
+
- **Description**: Controls whether the plugin checks for and installs updates from npm.
|
|
255
|
+
- **Effect**:
|
|
256
|
+
- **Dynamic UI Sync**: Disabling the toggle hides the **Check for updates** button and version badge in the header immediately without requiring a full page reload;
|
|
257
|
+
- **Endpoint Guard**: When disabled, the update API route returns `HTTP 403` for all check and install requests, preventing unreviewed updates;
|
|
258
|
+
- **Host / Platform Lock**: For curated plugin indexes (such as VibeDev) or restricted enterprise environments, this can be locked directly via Cordis configuration (bundle patch) without needing UI interaction:
|
|
259
|
+
```yaml
|
|
260
|
+
updater: false # or onlineUpdate: false
|
|
261
|
+
```
|
|
262
|
+
Once configured, the updater is disabled at startup, the update action stays hidden, and the online-update switch is disabled. The host lock takes precedence over the user's choice in `channels.json` and cannot be lifted through the UI. Removing the host lock restores the saved user preference.
|
|
263
|
+
- **Update Modes**: When a newer release is available, **Update automatically** runs only when the DSH CLI or Desktop update service is available; otherwise, the dialog provides a profile-specific manual command to copy and run.
|
|
239
264
|
|
|
240
265
|
## Usage
|
|
241
266
|
|
package/README.zh-CN.md
CHANGED
|
@@ -205,6 +205,7 @@ IM 消息发起的处理结束后,会在正文和文件投递完成后给出
|
|
|
205
205
|
- 以下示例使用 `web` profile;请替换为实际目标 profile。
|
|
206
206
|
- 从源码安装或二次开发需要 Node.js 22+;仅从 npm 安装无需在任意目录执行 `npm install`。
|
|
207
207
|
- 安装后必须重启 `dsh web`,并在浏览器硬刷新,才能看到「设置 → IM助理」。
|
|
208
|
+
- **反向代理部署**:支持将 DSH 部署在带路径前缀的反向代理后面(如 `/app/dsh/`),插件 API 与更新检查端点统一自动按页面基址(`document.baseURI`)相对解析,避免丢失代理路径前缀导致 404。
|
|
208
209
|
|
|
209
210
|
## 安装
|
|
210
211
|
|
|
@@ -233,9 +234,33 @@ dsh --profile web --dump-config
|
|
|
233
234
|
|
|
234
235
|
配置输出中应包含 `im-connect`。安装后重启 DSH Web 并在浏览器硬刷新。不要手工复制客户端文件,`dsh plugin add` 会同时应用 `cordis.patch.yml`。
|
|
235
236
|
|
|
236
|
-
##
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
## 插件配置与可选开关
|
|
238
|
+
|
|
239
|
+
插件遵循 DSH 官方扩展配置规范,配置项位于:
|
|
240
|
+
> **主界面侧边栏「插件」→ 点击 `@michengai/dsh-im-connect` 详情页**(对应宿主 `plugins.bundle.config` 槽位)。
|
|
241
|
+
|
|
242
|
+
此处提供两个原生扁平行开关。界面开关值保存在插件 `stateDir` 下的 `channels.json` 中,重启后保留;它们不是两个等价的 Cordis YAML 配置项。`sidebarEntry` 只通过此界面管理,`onlineUpdate` 另受下述宿主锁定规则约束:
|
|
243
|
+
|
|
244
|
+
### 1. 侧边栏入口 (`sidebarEntry`)
|
|
245
|
+
- **默认状态**:关闭(`false`)
|
|
246
|
+
- **功能说明**:在宿主左侧主导航栏增加常驻的 **「即时通讯」** 图标入口。
|
|
247
|
+
- **生效效果**:
|
|
248
|
+
- 开启后,在侧边栏点击即可直达 IM 助理中心,并在主工作区以 **960px 居中版心**(对齐官方插件管理与市场规范)展开完整大面板,彻底告别在设置弹窗狭窄视口内滚动的局限;
|
|
249
|
+
- 关闭后安全注销侧栏槽位(若当前正停留在 IM 面板,会自动安全切回默认视图,防止悬空和白屏);
|
|
250
|
+
- 无论是否开启侧栏入口,DSH 原有的「设置 → IM助理」入口始终保留,两处界面数据与状态 100% 实时同步。
|
|
251
|
+
|
|
252
|
+
### 2. 在线更新 (`onlineUpdate` / `updater`)
|
|
253
|
+
- **默认状态**:开启(`true`)
|
|
254
|
+
- **功能说明**:控制是否允许在线检查并安装 IM 连接器的新版本。
|
|
255
|
+
- **生效效果**:
|
|
256
|
+
- **界面联动**:关闭开关后,IM 管理面板标题旁的「检查更新」按钮与版本提示将即时隐藏,无需刷新页面;开启后自动恢复展示;
|
|
257
|
+
- **接口安全拦截**:关闭后,服务端的更新路由对任何版本检查和安装请求均返回 `HTTP 403` 禁用状态,彻底杜绝在插件内安装未审核版本;
|
|
258
|
+
- **宿主/平台级锁定**:面向精选插件索引(如 VibeDev)或企业安全合规环境,支持直接在 Cordis 配置文件(bundle patch)中声明,无需进入界面手动配置:
|
|
259
|
+
```yaml
|
|
260
|
+
updater: false # 或 onlineUpdate: false
|
|
261
|
+
```
|
|
262
|
+
配置生效后,更新器在启动时即被禁用,更新入口隐藏,详情页在线更新开关置灰。宿主锁定优先于 `channels.json` 中的用户选择,界面不能解除锁定;宿主移除锁定后,重新按已保存的用户选择生效。
|
|
263
|
+
- **更新模式**:发现新版后,只有检测到 DSH CLI 或 Desktop 更新服务时才可使用“自动更新”;其他环境会在弹窗中提供可复制、与当前 Profile 对应的手工更新命令。
|
|
239
264
|
|
|
240
265
|
## 使用
|
|
241
266
|
|
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,6 +610,8 @@ 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
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}",
|
|
@@ -638,6 +641,8 @@ 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
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}",
|
|
@@ -844,7 +849,7 @@ window.__ModuleLoader__.load({
|
|
|
844
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}
|
|
845
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}
|
|
846
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}}
|
|
847
|
-
|
|
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)}
|
|
848
853
|
`;
|
|
849
854
|
|
|
850
855
|
const TITLE_LINK_CSS = "@media(max-width:720px){.ima-title-row{flex-wrap:wrap}}";
|
|
@@ -945,7 +950,8 @@ window.__ModuleLoader__.load({
|
|
|
945
950
|
request.headers = Object.assign({ "content-type": "application/json" }, request.headers || {}, { "x-dsh-im-connect-client": "1" });
|
|
946
951
|
if (request.body === undefined) request.body = "{}";
|
|
947
952
|
}
|
|
948
|
-
|
|
953
|
+
const targetUrl = typeof resolveApiUrl === "function" ? resolveApiUrl(API_BASE + path) : API_BASE + path;
|
|
954
|
+
return fetch(targetUrl, request).then((r) => r.json()).then((data) => {
|
|
949
955
|
if (!request.signal?.aborted && data.ok && Array.isArray(data.groups)) updateChannelMembership(data.groups);
|
|
950
956
|
return data;
|
|
951
957
|
});
|
|
@@ -1735,8 +1741,12 @@ window.__ModuleLoader__.load({
|
|
|
1735
1741
|
if (!next) { setHint(t("error.chooseWorkspace")); return Promise.resolve(); }
|
|
1736
1742
|
if (typeof props.createWorkspace !== "function") { setHint(t("error.workspaceUnavailable")); return Promise.resolve(); }
|
|
1737
1743
|
setAddBusy(true);
|
|
1738
|
-
return Promise.resolve(props.createWorkspace({ path: next })).then((created) => {
|
|
1739
|
-
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
|
+
}
|
|
1740
1750
|
update({ cwd: cwdPath });
|
|
1741
1751
|
}).catch((error) => setHint((error && error.message) || t("error.addWorkspace")))
|
|
1742
1752
|
.finally(() => setAddBusy(false));
|
|
@@ -3300,19 +3310,33 @@ window.__ModuleLoader__.load({
|
|
|
3300
3310
|
}
|
|
3301
3311
|
openListed(id);
|
|
3302
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
|
+
});
|
|
3303
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
|
+
});
|
|
3304
3328
|
const channelView = h(ChannelOfficialView, {
|
|
3305
3329
|
officialTree: Official,
|
|
3306
|
-
hostProps:
|
|
3330
|
+
hostProps: guardedHostProps,
|
|
3307
3331
|
hostT: officialT,
|
|
3308
3332
|
t,
|
|
3309
3333
|
openSession,
|
|
3310
3334
|
openChannelSettings: props.openChannelSettings,
|
|
3311
3335
|
openImSettings: props.openImSettings,
|
|
3312
3336
|
});
|
|
3313
|
-
if (props.wide === false) return Official ? h(Official,
|
|
3337
|
+
if (props.wide === false) return Official ? h(Official, guardedOfficialProps) : null;
|
|
3314
3338
|
const officialTree = Official
|
|
3315
|
-
? h("div", { className: "ima-official-tree" }, h(Official,
|
|
3339
|
+
? h("div", { className: "ima-official-tree" }, h(Official, guardedOfficialProps))
|
|
3316
3340
|
: null;
|
|
3317
3341
|
const visibleTab = resolveSidebarTab(tab, extraTabs);
|
|
3318
3342
|
const extra = extraTabs.find((item) => item.id === visibleTab);
|
|
@@ -3463,6 +3487,330 @@ window.__ModuleLoader__.load({
|
|
|
3463
3487
|
|| component.__dshAutomationOriginal !== undefined);
|
|
3464
3488
|
}
|
|
3465
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
|
+
|
|
3466
3814
|
function apply(ctx) {
|
|
3467
3815
|
ensureStyle();
|
|
3468
3816
|
ctx.effect(() => {
|
|
@@ -3495,6 +3843,25 @@ window.__ModuleLoader__.load({
|
|
|
3495
3843
|
}), "im-connect: channel membership");
|
|
3496
3844
|
ctx.effect(() => ctx.locale.register(IM_LOCALE_NS, IM_LOCALES), "im-connect: dictionaries");
|
|
3497
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");
|
|
3498
3865
|
ctx.effect(() => observePluginUpdate({
|
|
3499
3866
|
endpoint: "/api/michengai/dsh-im-connect/update",
|
|
3500
3867
|
packageName: "@michengai/dsh-im-connect",
|
|
@@ -3503,10 +3870,8 @@ window.__ModuleLoader__.load({
|
|
|
3503
3870
|
zhName: t("settings.title"),
|
|
3504
3871
|
enName: t("settings.title"),
|
|
3505
3872
|
createIcon: createPluginUpdateIcon,
|
|
3873
|
+
isEnabled: () => sidebarController.isOnlineUpdateEnabled(),
|
|
3506
3874
|
}), "im-connect: plugin update ui");
|
|
3507
|
-
const permissionT = ctx.locale.bind("permission.access");
|
|
3508
|
-
const modelT = ctx.locale.bind("model");
|
|
3509
|
-
const presetT = ctx.locale.bind("settings.agentPreset");
|
|
3510
3875
|
const subscribeLocale = (listener) => ctx.locale.subscribe(listener);
|
|
3511
3876
|
const localeSnapshot = () => ctx.locale.getSnapshot();
|
|
3512
3877
|
const openChannelSettings = (request) => {
|
|
@@ -3630,7 +3995,7 @@ window.__ModuleLoader__.load({
|
|
|
3630
3995
|
icon: "chat",
|
|
3631
3996
|
locale: IM_LOCALE_NS,
|
|
3632
3997
|
inject: () => ({
|
|
3633
|
-
createWorkspace: (input) => ctx.workspaces.create(input),
|
|
3998
|
+
createWorkspace: typeof ctx.workspaces?.create === "function" ? (input) => ctx.workspaces.create(input) : undefined,
|
|
3634
3999
|
pickDirectory: () => pickHostDirectory(ctx),
|
|
3635
4000
|
permissionT,
|
|
3636
4001
|
modelT,
|
|
@@ -3814,6 +4179,8 @@ window.__ModuleLoader__.load({
|
|
|
3814
4179
|
|
|
3815
4180
|
exports.apply = apply;
|
|
3816
4181
|
exports.inject = inject;
|
|
4182
|
+
exports.resolveApiUrl = resolveApiUrl;
|
|
4183
|
+
exports.setupSidebarEntry = setupSidebarEntry;
|
|
3817
4184
|
return module.exports;
|
|
3818
4185
|
},
|
|
3819
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"}
|