前言¶
在 Windows 上用 DSH Desktop 的開發者,多半碰到過三類麻煩:
1、桌面端生成的 pnpm 命令在路徑含中文時亂碼,裝插件直接報「系統找不到指定的路徑」;
2、市場(dshmarket)更新只作用於 desktop profile,web 側得手動再裝一遍;
3、pnpm 會攔截 24 小時內發佈的新包,剛上架的插件裝不上。
dsh-client-fix 針對的就是這三件事。下面介紹它的功能、安裝方式和注意點。
這是什麼¶
dsh-client-fix 是由 labi43186-spec 維護的 DSH Desktop 客戶端修復插件,MIT 許可證,當前版本 1.5.0,peerDependencies 爲 @deepseek-ai/cordis ^4.0.1。它做三件事:修復 pnpm shim 的編碼 bug、把 web profile 自動同步成與 desktop 一致、在安裝前預加 minimumReleaseAgeExclude 豁免。README 註明使用 DeepSeek-V4-Flash 製作。
核心功能¶
修復 pnpm shim 編碼 bug¶
DSH Desktop 啓動時生成 runtime-commands/bin/pnpm.cmd,該文件以 UTF-8 寫入,但 cmd.exe 按 GBK(936) 讀取。路徑裏帶中文時(如 D:\軟件\...)解析亂碼,報「系統找不到指定的路徑」。
插件的處理方式:啓動 3 秒後自動給 shim 第二行補一行 chcp 65001 >nul(無 BOM),跨代碼頁通用。桌面應用重啓後若重新生成了壞 shim,插件會自動再次修復,不需要人工介入。
fs.watch 自動同步 web(向 desktop 對齊)¶
插件監聽 desktop profile 的 package.json 與 pnpm-lock.yaml,變化後防抖 800ms,把 web profile 同步成與 desktop 一致:
- desktop 有、web 無 → 補裝
- desktop 無、web 有 → 移除(尊重手動卸載)
- 版本不同 → 對齊 desktop 版本
市場(dshmarket)更新只操作 desktop,web 由本插件自動跟隨,無需手動操作。
預加 minimumReleaseAgeExclude 豁免¶
pnpm 會攔截 24 小時內發佈的新包,報 ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION。插件在安裝前自動把 pkg@version 寫入 pnpm-workspace.yaml 的 minimumReleaseAgeExclude,讓剛發佈的包能直接裝上。
安裝與啓用¶
包已發佈到 npm,兩種裝法選一種即可。
裝到 web profile(市場默認操作目標,裝完會自動同步到 desktop):
dsh plugin --profile web add dsh-client-fix
或直接裝到 desktop profile(桌面應用實際加載的 profile,裝完後 fs.watch 會自動把 web 同步上):
dsh plugin --profile desktop add dsh-client-fix
兩種方式等價,區別只在先落哪一個 profile,之後都會被自動同步補齊。注意用 npm 包名安裝,不要寫路徑。
本地開發調試時,可用 link: 指向源碼目錄:
dsh plugin --profile desktop add link:C:/dshplugins/dsh-client-fix
源碼目錄建議放在無空格路徑下,含空格路徑會被 dsh→pnpm 轉發截斷。
內置接口¶
插件提供三個接口:
/dsh-client-fix/status:查看 desktop/web 插件版本對比與同步狀態/dsh-client-fix/sync:手動觸發一次同步(向 desktop 對齊)/dsh-client-fix/repair-shims:手動修復 pnpm/node shim 編碼
自動機制之外,可以用它們手動觸發同步或修 shim。
適用場景與注意¶
適合這些情況:
- Windows + DSH Desktop,安裝路徑含中文,
dsh plugin報「系統找不到指定的路徑」 - 同時使用 web 與 desktop profile,不想每次市場更新後手動同步兩邊
- 需要安裝剛發佈、還沒過 pnpm 24 小時時間限制的插件
安裝前注意:
- 插件以當前 dsh 進程權限運行,建議先到 GitHub 檢查源碼與許可證(MIT)再安裝
- 用 npm 包名安裝,不要寫路徑
link:本地調試時,源碼目錄不要含空格
小結¶
dsh-client-fix 把桌面端三件重複性的事——修 shim 編碼、同步 web 與 desktop、豁免新包安裝——交給了插件自動處理,裝完之後基本不用再管。DSH 的理念是「一切皆插件」,客戶端側的這類修復由插件來補齊,正是這個思路的體現。
- 目錄頁:https://www.skillhub.cn/plugins/labi43186-spec/dsh-client-fix
- 源碼:https://github.com/labi43186-spec/dsh-client-fix
(目錄爲社區獨立維護的站點,與 DeepSeek / 幻方無官方從屬關係。)