dsh-plugin-toggles

August 18, 2026 · View on GitHub

DSH Web GUI 的「插件开关」插件:在 设置 → 插件 → 开关 页签列出所有第三方插件, 每个插件一行开关,关闭/开启即时作用于后端(插件服务停止/启动)并持久化。

功能

  • 列表范围:所有非 @deepseek-ai 的第三方 loader 条目(sshui-task-boardui-dsh-aionui-paneldshmarketdsh-memory-evolve…),排除 group 容器与插件自身。
  • 关闭需确认;开启直接生效。
  • 后端立即生效;浏览器端界面(侧边栏入口等)需刷新页面后完全消失/恢复。
  • 持久化:开关状态写入 profile 的 cordis.patch.yml- id: <行id> + disabled: 覆盖), 由 DSH 的 HMR 配置监听热应用,重启后依然生效。

安装

将本包加入目标 profile(如 ~/.dsh/profiles/<profile>/package.json)的依赖, 并在 dsh.profile.bundles 追加 dsh-plugin-toggles;随后在 profile 目录运行 pnpm install(或手动在 node_modules 建立指向本包的链接)。包自带的 cordis.patch.yml 会以 bundle 补丁形式插入插件行。

本地源码依赖(无需 npm 发布):

{
  "dependencies": {
    "dsh-plugin-toggles": "file:路径/dsh-plugin-toggles"
  },
  "dsh": {
    "profile": { "bundles": [ "...", "dsh-plugin-toggles" ] }
  }
}

或直接把它作为 bundle 挂在 profile 的补丁层(等效于本仓库 cordis.patch.yml 的内容):

- insert:
    - id: dsh-plugin-toggles
      name: dsh-plugin-toggles

插件行挂载后由 DSH 的配置 HMR 热应用;宿主端代码修改后需重启 DSH 进程才重新 导入(Node ESM 缓存,配置热重载不重载插件源码);浏览器端 bundle 由刷新页面加载。

架构

  • 宿主端 lib/index.js:Cordis 插件,暴露两个 HTTP 路由
    • GET /api/dsh-plugin-toggles/list{ plugins: [{id, name, disabled, running}] }
    • POST /api/dsh-plugin-toggles/set(body {id, disabled})→ 调 entry.update({disabled}) 即时停/启,并把覆盖写进 cordis.patch.yml(用 entry.options.id,即组合文件里的行 id; 运行时 entry.idinclude: 前缀,不能用于补丁匹配)。
  • 浏览器端 client/client.js__ModuleLoader__ bundle,注册 settings.plugins.tabtoggles 页签,通过 fetch 调宿主路由。

开发

  • 修改代码后需要重启 DSH 进程才会重新导入宿主模块(Node ESM 缓存,配置热重载 不会重载插件源码);客户端 bundle 由刷新页面加载。
  • 持久化只写 cordis.patch.yml,不触发 loader 的 cordis.yml 拍平,避免与 bundle 补丁重复插入冲突。