dsh-desktop-restart
v0.1.0
Published
Tray restart command for DSH Desktop
Maintainers
Readme
dsh-desktop-restart
DSH Desktop 插件:在系统托盘菜单中添加 重启 DSH Desktop…,无需再手动找可执行文件重启应用。
功能
- 在原生托盘菜单的 工具(Tools) 分组中添加重启命令
- 菜单文案随桌面语言切换(English / 中文)
- 重启进行中会禁用菜单项,避免重复触发
- 通过 Cordis 与 bundle patch 接入 DSH Desktop
环境要求
- 支持插件的 DSH Desktop
- 本地开发需要 Node.js
>=22.0.0和 Yarn 1.x
安装
在 DSH Desktop 托盘 → Open DSH Terminal 中执行以下命令之一:
# npm(发布后推荐)
dsh plugin add dsh-desktop-restart
# GitHub(首次安装可能需要放行构建脚本)
dsh plugin add github:SanShuiGieGie/dsh-desktop-restart
# 本地开发
dsh plugin add link:/path/to/dsh-desktop-restart安装完成后,请完全退出并重新打开 DSH Desktop,插件才会生效。
本地开发安装
使用 link: 时需先构建插件:
cd /path/to/dsh-desktop-restart
yarn install
yarn run build
dsh plugin add link:/path/to/dsh-desktop-restart然后完全退出并重新打开 DSH Desktop。
说明: 若在 Node 23 上
yarn install因依赖的engines检查失败,本仓库已提供.yarnrc(ignore-engines true)。也可改用 Node 22 LTS 或 Node 24+。
使用
- 打开 DSH Desktop 托盘菜单。
- 点击 Restart DSH Desktop…(桌面语言为中文时显示 重启 DSH Desktop…)。
- DSH Desktop 会先正常退出,再自动重新启动。
重启请求处理期间,该菜单项会暂时禁用。
卸载
dsh plugin remove dsh-desktop-restart卸载后同样需要重启 DSH Desktop。
开发
# 安装依赖
yarn install
# 编译 TypeScript 到 lib/
yarn run build
# 运行单元测试
yarn run test
# 仅类型检查(不输出文件)
yarn run typecheck
# 完整检查(构建 + 导出验证 + 类型检查 + 测试)
yarn run check项目结构
| 路径 | 说明 |
|------|------|
| src/index.ts | Cordis 插件入口 — 监听 desktopRuntime 并挂载托盘项 |
| src/host/tray.ts | 在原生托盘中注册重启命令 |
| src/host/locale.ts | 中英文托盘文案 |
| cordis.patch.yml | 将插件插入 DSH Desktop 的 Cordis bundle |
| tests/ | Vitest 单元测试 |
工作原理
DSH Desktop 会在 Cordis 上下文中提供 desktopRuntime 服务。本插件:
- 等待
desktopRuntime就绪(或在其后续出现时响应)。 - 通过
registerTrayItem()注册托盘项,分组为tools,排序为30。 - 点击时调用
desktopRuntime.requestRestart(),先 orderly 地关闭 Cordis,再由 Electron 重新启动。
插件通过 cordis.patch.yml 注入桌面 bundle:
- insert:
- id: desktop-restart
name: dsh-desktop-restart