DSH HUB
HomePlugin StorePlugin PacksCommunityRankingsResourcesPublish Guide
Plugin source
Back to catalog

liuhao11223 /

liuhao11223/dsh-oneclick-restart

Verified

dsh重启按钮插件

★ 0 Stars0 Forks0 IssuesN/A Community rating0 Confirmed installs
View on GitHub
READMESource: main@e2ce1b74

dsh-oneclick-restart

DSH Web 侧边栏底部的一键重启 Harness 按钮(DSH Desktop)。

![位置] 侧边栏最底部、Settings 行上方的 sidebar.footer.action 座位:展开时是 「⟳ 重启 Harness」整行按钮,侧栏收起时自动变成 36px 圆形图标按钮(与 Cordis 插件入口同款)。

它做什么

一次点击调用 window.dshDesktop.restartHarness() —— DSH Desktop preload 桥接的 harness:restart IPC,等同于原生菜单里的「重启 Harness」:

  • 停掉当前 Harness 进程并重新拉起(重新扫描插件树、生成新的 auth URL);
  • 复用同一个窗口,服务回来后窗口自动加载新地址;
  • 当前正在进行的对话会被中断(按钮 tooltip 已说明)。

按钮在请求进行中显示旋转图标、文案变「正在重启…」并禁用,防止重复点击。

状态

相位 文案 说明
idle 重启 Harness 可点击
restarting 正在重启… 图标旋转,按钮禁用
unsupported 仅桌面端可一键重启 纯浏览器标签页里没有 window.dshDesktop,4 秒后复原
failed 重启失败,请重试 IPC 抛错或 { ok: false },4 秒后复原可重试

安装

方式一:CLI(需要 dsh CLI)

dsh plugin --profile web add dsh-oneclick-restart
dsh plugin --profile web add link:<本目录绝对路径>   # 本地开发

方式二:手工安装(不经 CLI)

  1. 把整个包目录复制到 profile 的 node_modules:

    $DSH_HOME/profiles/web/node_modules/dsh-oneclick-restart/
    
  2. 在 $DSH_HOME/profiles/web/cordis.patch.yml(你自己的 patch 层)里加一条 insert:

    - insert:
        - id: dsh-oneclick-restart
          name: dsh-oneclick-restart
    
  3. 让 Harness 重新加载:profile 的 patchReload: live 通常会即时生效,随后刷新页面 即可看到按钮;若没生效,用原生菜单「重启 Harness」重启一次。

Windows 上 $DSH_HOME 默认为 %APPDATA%\dsh-desktop\harness(本仓库附带的 install.ps1 就是按这个默认值做上面两步的,可重复执行)。

注意:profile 的 node_modules 由 pnpm 管理,一次 pnpm install 可能清掉手工放进去的 目录;被清掉后重新复制即可(或用方式一安装)。

包结构

package.json        dsh.client = { platform: 'web' },导出 ./client 浏览器 bundle
cordis.patch.yml    bundle 挂载声明(insert 条目)
lib/index.js        宿主半侧:无行为,仅作为“已启用的 Loader 条目”
lib/client.js       浏览器半侧:模块加载器 bundle(注册槽位 + 组件 + 样式 + 词典)
test/client.test.mjs 组件级功能验证(jsdom + react-dom)

实现要点

  • 客户端 bundle 走 DSH 的客户端模块系统:window.__ModuleLoader__.load({ id, factory }), id 即包名;只 require 平台种子表内的模块(react、 @deepseek-ai/dsh-client-ui-primitives),因此无需 dsh.client.external / inject。
  • 槽位注册:ctx.slots.inject('sidebar.footer.action', () => ctx.slots.register({...}, Component))。 该座位由 @deepseek-ai/dsh-client-ui-sidebar 声明为 list / scope: root,组件收到 { wide }(侧栏是否展开)与 t(本插件词典)。
  • 样式:<style data-plugin data-plugin-css> 注入,类名前缀 ocr1_,颜色全部使用 主题 CSS 变量(--dsw-alias-*),暗色/亮色与字体缩放自动跟随。
  • 词典:ctx.locale.register('oneclick-restart', { zh, en }),两份词典键集一致。

验证

node test/client.test.mjs

用真实 react/react-dom/jsdom 跑:模块加载、槽位注册形状、宽/窄两态渲染、中英文案、 单击只调用一次桥接、重启中禁点、无桥接降级提示、失败提示、样式注入。

测试从 DSH Desktop profile 的 node_modules 借用 react / react-dom / jsdom(不额外装依赖); profile 不在默认位置时用 DSH_PROFILE_MODULES 指向一个含这三个包的 node_modules。

许可

MIT

—/ 5

No ratings yet

Verified DSH bundle

Commit e2ce1b7433dd

Community comments

No comments yet. Be the first to write one.

DSH HUB

A community index for DSH plugins. Not an official GitHub or DeepSeek AI product.

CommunityResourcesAPIAbout