dsh-titlebar-restart
Manifest validWindows Desktop only. Adds a 重启 item to the DSH window caption menubar next to 应用 and 编辑; the second click stops the app and starts the same executable again through a WMI-spawned PowerShell helper.
dsh-titlebar-restart
中文 | English
仅 Windows 桌面版。在 DSH 窗口标题栏菜单(应用 / 编辑)后加一个「重启」项,连点两次即由 WMI 拉起的 PowerShell 脚本结束应用并重新启动同一个可执行文件。
分类:开发与运行时(dev) · 安装:dsh plugin --profile <profile> add dsh-titlebar-restart

它做什么
标题栏菜单由 Electron 的 preload 绘制,不在 Web 插槽体系里,所以插件有两半:
- 宿主半:在 Connection 通道注册一条带 Cookie 鉴权的路由
POST /api/titlebar-restart(走ctx.connection.fetch)。Connection 插件会先做 Host/Origin 校验与会话 Cookie 校验,未通过者根本到不了本插件。 - 浏览器半:等 preload 挂出
[data-windows-menu]这个开放 shadow root,往它的[role=menubar]里追加一个<button role="menuitem">。样式直接继承 preload 自带的button { ... }规则,所以和 编辑 完全一致,而不是「看起来差不多」。
点一下变成 确认重启,四秒内再点一下变成 重启中…,这一下才真正 POST。
重启是怎么执行的
宿主先写出一小段 PowerShell,再用 WMI(Win32_Process.Create)拉起它。脚本的父进程
因此是 WmiPrvSE 而不是即将被结束的进程树,于是它能活到把活儿干完:
- 等约 0.9 秒,让 HTTP 响应先回到浏览器;
- 结束 Electron 主进程与本 Host;
- 等监听端口释放;
- 重新启动同一个可执行文件。
整体约 3~4 秒。日志与生成的脚本在 %TEMP%\dsh-titlebar-restart\(restart.log、
restart.ps1、launch.ps1)——万一哪次重启没回来,可以直接手动跑 restart.ps1。
Program Files 下的任何文件都没有被改动:这就是一个普通的 profile 插件,桌面版升级
不会把它覆盖掉。
环境要求
- Windows 上的 DSH 桌面版。 标题栏菜单是桌面窗口才有的东西;用
dsh web起的 服务没有窗口也没有菜单行,路由会返回409 not-desktop,浏览器半保持静默。macOS 与 Linux 不支持。 - Node 22+(桌面版运行时本来就满足)。
安装
在插件市场里(插件 → 发现)安装,或者:
dsh plugin --profile <profile> add dsh-titlebar-restart
没发 npm 包时,也可以直接从仓库装(需要本机有 git):
dsh plugin --profile <profile> add github:NyaNyaHua4290/dsh-titlebar-restart
装完重启一次 DSH,让 bundle 挂载。
安全说明
- 路由只对持有 Web UI 会话 Cookie 的请求开放,未鉴权的请求在 Connection 层就被拒, 不会到达本插件。
- 只有当 Host 的父进程是 Electron 桌面壳时才动作——用
dsh web启动时它不会去结束 你的终端。 - 点重启会中断正在运行的一切,包括当前这一轮对话。会话会落盘,重启后自动恢复。
卸载
从 profile 里移除插件(市场 → 卸载,或 dsh plugin remove)。生成的脚本留在
%TEMP%\dsh-titlebar-restart\,直接删掉即可。
许可证
MIT
Comments
Loading…
Similar plugins
by wangbofan
DSH desktop (Windows) titlebar menu: a Restart button that closes and relaunches the whole app - shell + Host. Plugin-only, no app.asar patching.
★ 0
MIT
JavaScript
Oct 14, 2026
dsh plugin --profile web add dsh-restart-buttonby Re-qi
DSH 桌面端 Windows 标题栏一键重启按钮:点击后关闭 DSH 并自动重新拉起同一个应用。One-click restart button in the DSH desktop title bar (Windows).
★ 0
MIT
JavaScript
Oct 31, 2026
dsh plugin --profile web add dsh-topbar-restartby 978064659
Adds a restart button to the Windows title bar, left of the minimize control, that stops and relaunches the desktop shell together with its Harness Host so a newly installed plugin takes effect.
★ 0
MIT
JavaScript
Oct 26, 2026
dsh plugin --profile web add dsh-restart-buttonA restart button in the window title strip, right of the sidebar toggle, that stops every process the desktop app owns (Electron shell, Host, renderers and tool subprocesses) and starts the executable
★ 0
dsh plugin --profile web add dsh-restart-appby mostkia
Power controls (shutdown / restart) for the DSH sidebar plus a Windows tray launcher with start-at-logon.
★ 0
MIT
PowerShell
Oct 5, 2026
dsh plugin --profile web add @mostkia/dsh-launcherby penghao73551
Two round buttons at the foot of the DSH desktop sidebar on Windows: restart the app without a console window ever flashing on screen, and open the DeepSeek top-up page in your browser. The restart pa
★ 0
MIT
JavaScript
Oct 30, 2026
dsh plugin --profile web add dsh-desktop-quick-actions