前言¶
做 DSH Desktop 插件時,先驗證安裝鏈路、再參考最小實現,是常見路徑。dsh-plugin-restart-desktop 是一個行爲單一的 DSH Desktop 插件:它在側邊欄左下角添加一個「重啓Desktop」按鈕,點擊後經二次確認調用桌面主進程有序重啓。下面介紹它的功能、安裝步驟和使用注意。
這是什麼¶
dsh-plugin-restart-desktop 是一個 DSH Desktop 插件,倉庫地址爲 https://github.com/ExploringBB/dsh-plugin-restart-desktop,許可證爲 MIT。它只負責一件事:在側邊欄底部設置行中注入「重啓Desktop」按鈕,並在確認後用桌面主進程完成有序重啓。
它也可以作爲 DSH Desktop 插件的最小示例,參考其中的五件套包結構、cordis.patch.yml 的 insert 補丁,以及 host/client 雙側與 Typert Remote 寫法。
核心功能¶
- 按鈕注入在側邊欄底部設置行內,位於齒輪右側。
- 點擊按鈕後彈出二次確認框;確認後調用
desktopActions.requestRestart()(Electron relaunch)進行有序重啓。 - 重啓過程中顯示「正在重啓…」等待層。
- 按鈕文案接入 DSH 語言系統;在
DSH 設置 → 通用設置 → 語言中切換中文 / English 後,文案立即切換。 - 僅 desktop profile 生效;headless web profile 下調用會得到
{ ok: false },並彈出友好錯誤提示。
安裝與啓用¶
該插件只適用於 desktop profile。安裝時需要修改 desktop profile 的 package.json,把插件加入 dependencies 與 dsh.profile.bundles。
先編輯 desktop profile 的 package.json,例如路徑爲:
~/.dsh/profiles/desktop/package.json
加入插件依賴和 bundle 配置:
"dependencies": {
"dsh-plugin-restart-desktop": "file:<本機插件目錄>"
},
"dsh": {
"profile": {
"bundles": [
"@deepseek-ai/dsh-base",
"@deepseek-ai/dsh-web-app",
"dsh-plugin-restart-desktop"
]
}
}
file: 後面的路徑需要替換爲插件在本機的實際目錄。
然後在該 profile 目錄執行安裝:
pnpm install
最後重啓 DSH Desktop。經過上面的步驟,左下角設置行內應能看到「重啓Desktop」按鈕。
典型用法¶
- 重啓 DSH Desktop 後,在側邊欄底部設置行、齒輪右側看到「重啓Desktop」按鈕。
- 點擊按鈕,在二次確認框中確認後,插件觸發有序重啓並顯示「正在重啓…」等待層。
- 在
DSH 設置 → 通用設置 → 語言中切換中文 / English,按鈕文案立即切換。 - 如果當前運行的是 headless web profile,調用會得到
{ ok: false }和友好錯誤提示。
包聲明要點¶
package.json 中聲明瞭如下依賴:
{
"dependencies": {
"zod": "^4.4.3"
},
"peerDependencies": {
"@deepseek-ai/cordis": "^4.0.1",
"@deepseek-ai/cordis-plugin-loader": "^1.0.2",
"@deepseek-ai/dsh-typert-protocol": "^0.1.0-rc.6",
"react": "^18.2.0"
}
}
其中還聲明瞭 client 注入項:
{
"dsh": {
"client": {
"inject": [
"@deepseek-ai/dsh-client-runtime",
"@deepseek-ai/dsh-api-remotes"
],
"platform": "web"
}
}
}
適用場景與注意¶
適合:
- 驗證 DSH Desktop 插件安裝流程:profile 註冊、pnpm install、重啓生效。
- 作爲自研 DSH Desktop 插件的最小參考實現。
- 查看 cordis.patch.yml 的 insert 補丁、host/client 雙側與 Typert Remote 寫法。
注意:
- 該插件僅適用於 desktop profile;headless web profile 下不可用,並返回 { ok: false }。
- 插件會作爲 desktop profile 的一部分被 DSH Desktop 加載,並以當前 dsh 進程權限運行;安裝前應檢查源碼、MIT 許可證和依賴版本。
- 安裝步驟中的 file: 路徑需要替換爲本機插件目錄,不要照抄佔位路徑。
小結¶
dsh-plugin-restart-desktop 覆蓋 DSH Desktop 插件的幾個安裝與運行鏈路:profile 註冊、依賴安裝、界面注入、語言系統和重啓流程。它適合做安裝驗證或最小插件示例。
倉庫地址:https://github.com/ExploringBB/dsh-plugin-restart-desktop