READMESource: master@ba4a098e
dsh-plugin-manager 自定义插件管理
DSH Web 设置页内的「自定义插件」管理页:查看、启用/禁用、删除已安装插件(删除带二次确认),支持热插拔 —— 开关插件即时生效,无需重启服务。
功能
- 📋 插件列表:名称、来源徽标(自建/第三方)、中文简介
- 🔘 一键启用/禁用:热插拔即时生效,服务不重启、不崩溃
- 🗑️ 删除插件(二次确认):pnpm remove + 清理 manifest + 从运行中的 loader 树移除
- 🎛️ 操作后自动轮询刷新列表;关闭管理器自身需二次确认
安装
方式一:DSH Web 插件市场(推荐)
在 DSH Web 的插件市场(如 dsh-plugin-hub / DSH-Plugins-Marketplace,按 GitHub dsh-plugin topic 收录)中搜索 dsh-plugin-manager 或 自定义插件管理,一键安装,重启 DSH 后生效。
方式二:命令行
# 在你的 web profile 中安装
dsh plugin --profile web add git+https://github.com/Yolotd/dsh-plugin-manager.git
# 重启 DSH
方式三:手动
- 克隆或下载本仓库;
- 把整个
dsh-plugin-manager文件夹复制到~/.dsh/profiles/web/node_modules/dsh-plugin-manager/; - 编辑
~/.dsh/profiles/web/package.json,在dependencies加"dsh-plugin-manager": "file:./node_modules/dsh-plugin-manager"; - 重启
dsh web。
安装后:打开 设置 → 自定义插件 即可管理插件。
使用
| 操作 | 说明 |
|---|---|
| 启用/禁用 | 点击开关;热插拔即时生效,无需重启(自身除外,需二次确认) |
| 删除 | 点击删除 → 确认删除?→ 移除依赖声明与运行条目 |
| 刷新 | 手动重新拉取列表 |
工作原理
- Host 半(
lib/index.js):提供/manager/*HTTP 路由;启用/禁用/删除通过 cordis loader 热插拔(ctx.loader.create / update(disabled) / remove)即时生效,manifest(dsh.profile.bundles/dependencies)负责跨重启持久化。 - Client 半(
lib/client.js):注册官方settings.section槽位(与 dsh-at-file 等第三方插件一致),导航/选中高亮/内容切换由官方设置面板管理。
注:早期版本曾在操作后
process.exit(42)软重启,会直接杀死单进程部署的 DSH 服务;现改为 loader 热插拔,进程永不退出。
接口
| 接口 | 说明 |
|---|---|
GET /manager/plugins |
插件列表(名称/来源/启用态/中文描述) |
POST /manager/plugins/<name>/toggle {"enable":true|false} |
启用/禁用 |
POST /manager/plugins/<name>/remove |
删除插件 |
开发
git clone https://github.com/Yolotd/dsh-plugin-manager.git
# 修改后复制 lib/ 到 ~/.dsh/profiles/web/node_modules/dsh-plugin-manager/lib/ 并重启 DSH
许可证
MIT
No comments yet. Be the first to write one.